From patchwork Thu Feb 8 09:05:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "He, Hongbo" X-Patchwork-Id: 10206785 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 53DCF60327 for ; Thu, 8 Feb 2018 09:09:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 495B929359 for ; Thu, 8 Feb 2018 09:09:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3DEAA29424; Thu, 8 Feb 2018 09:09:03 +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 9667829359 for ; Thu, 8 Feb 2018 09:09:02 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4A3156E448; Thu, 8 Feb 2018 09:06:54 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on0042.outbound.protection.outlook.com [104.47.36.42]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2DD056E47E; Thu, 8 Feb 2018 09:06:28 +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=RDXMhJEWL2Wel0V5q6RSiQNc8cSu/qtnUB3vdO+r4zk=; b=zMpIMGZIilQfkrDmpQ+s/qYuvLJ8Kxl1+sdBVU8mET5Ddl4VZeiN2svnoyEmcYgMLKTDV4prSyEJG+jELnNSA+k8H56MHkiLP4nl7ey/7ijZDCY4/lzUSxsDrb9bf6/KzuKi4Rmich5mfZoF9XmbJu02b8uV+875jMz+F/kyyp4= Received: from DM3PR12CA0052.namprd12.prod.outlook.com (10.161.151.20) by BN6SPR00MB03.namprd12.prod.outlook.com (10.172.112.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.485.11; Thu, 8 Feb 2018 09:06:25 +0000 Received: from CO1NAM03FT030.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e48::208) by DM3PR12CA0052.outlook.office365.com (2603:10b6:0:56::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.485.10 via Frontend Transport; Thu, 8 Feb 2018 09:06:25 +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 CO1NAM03FT030.mail.protection.outlook.com (10.152.80.169) 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; Thu, 8 Feb 2018 09:06:25 +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; Thu, 8 Feb 2018 03:06:16 -0600 From: Roger He To: , Subject: [PATCH 2/4] drm/ttm: add bit flag TTM_OPT_FLAG_FORCE_ALLOC Date: Thu, 8 Feb 2018 17:05:59 +0800 Message-ID: <1518080761-12952-2-git-send-email-Hongbo.He@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518080761-12952-1-git-send-email-Hongbo.He@amd.com> References: <1518080761-12952-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)(39380400002)(346002)(376002)(39860400002)(396003)(2980300002)(428003)(189003)(199004)(2906002)(106466001)(59450400001)(81166006)(50226002)(81156014)(8676002)(97736004)(8936002)(51416003)(356003)(305945005)(86362001)(575784001)(7696005)(5660300001)(47776003)(48376002)(104016004)(50466002)(186003)(336011)(53416004)(110136005)(54906003)(16586007)(316002)(26005)(77096007)(6666003)(2950100002)(105586002)(76176011)(53936002)(478600001)(68736007)(4326008)(36756003)(450100002)(72206003); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6SPR00MB03; H:SATLEXCHOV01.amd.com; FPR:; SPF:None; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; CO1NAM03FT030; 1:M4WLg5dkwNDodnqCuEvP38BZf1xQT3K1ofcoESbYAWPVP/RAitdBxpJ7wIcninzluLHSpvVqUC05QxYkFRrNj9Wm6XECUy28efuyiS7LCY0bb4MWBCGM3hBK46OGZ7Fa X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7572c724-9315-4a29-11df-08d56ed33b43 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060); SRVR:BN6SPR00MB03; X-Microsoft-Exchange-Diagnostics: 1; BN6S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3DL8uyWBhBX0wXDV1I2WZvPQH9XJom4O/YegAJPN5z73D3A5kYftoyfTVIbEYoK6+5jLM5xz/SRn4rABGpwucbI5jHMb4S0OWlKBsyv7UXBH1CpUMhMf8XJSzjLlKXjH+nNWvYNJ0o1ZiN5fNQ1IFSEX3/66verW6QSPrSng/bmNyR6PKvQyaPnu1x5vo+RRMIFv7OquJisXzWycd02BI70NyNfvINzeUnmtgjlZnC41/c7YgXfK5DX+f/MWtydB1xHDW1+oLzzyxgLAsW6lgoFj3zMtmro8iHU1Qe9x5vONPeFdM62EsLLbsELm3aPPef7FHbc6jB9voyEE2CMrV98fC7Z/KxefwrinEW8Jq++56TTkzQ/uzs/7nGu8BXpTsHnbOaqABKCSKLTvKgD+u04KAQMBZOydv49zM+d9S//c0H1GzBq3rNfIcsyxCnnj8xoX1xce6Trpo7gbNgihwMDV5 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)(3231101)(2400082)(944501161)(10201501046)(3002001)(93006095)(93003095)(6055026)(6041288)(20161123562045)(20161123560045)(20161123564045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:BN6SPR00MB03; BCL:0; PCL:0; RULEID:; SRVR:BN6SPR00MB03; X-Microsoft-Exchange-Diagnostics: 1; BN6SPR00MB03; 4:n0KFXUR9J1a+dk1vRr/r/KfxGvpQRtdeZIqO8zk4EbsB/oADTJv0JJAemw+G3o47yPsGTpQK31ZOyH/7itqWt+I+tYHEZeHnbdLjsGzrcNSrP7y6LqTHpMLVi6a+fb7ItgmN7S7llD2sROFCDKX+0A00MrGnXtcmSJEmvvnhqjk4reoA+VERq8CVQIWYLVsJUEwm9PrnrEoY6QdNiCfOdBUULo9/M3hCQM6sfMpXn6KwQmUQAPXrvdZ+wp9w+7cOduXkP7du343E7L7MjckTsT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dBWnjHwZoncd/4Qyn+Niz5QGI++xdWviSjBvQ4Dfp8dmalcn?= =?us-ascii?Q?KV2gXDWQ+JQPAofor8hM1NzTP1G0NDK2pqWkcY8LFX1he276qQHe/phlwn7D?= =?us-ascii?Q?JURXDiYbgF9nrFTf9+m2tmfAJX/prvjUk4mEfqxw13nO2C60HzMWkvEPQ7ef?= =?us-ascii?Q?e+4KzwYSrBv6eshyKQRN//Xo6dUl2EHdrx22YAS4Gwk51OKR5o+q+h8X23AE?= =?us-ascii?Q?2hf9LpfdcgoeWLDwhDyKvIkZiq7jRxONsSw0WXDu1ywsYGSLYM9C+xouulte?= =?us-ascii?Q?7gmoLzsq97ub5p5YDYs/NENMk9rKEBAIHjI2EnLxEvzCweIWYha0KxF1d7gP?= =?us-ascii?Q?W+c7igQ5APre2fyz20lcixJ8pcqyLe?= X-Microsoft-Exchange-Diagnostics: 1; BN6SPR00MB03; 6:2c53J82naF5DuPMUSQZLGJ6EJJ6u44KihavUjyRAMMpVx7uEZCQ7B7L1szQbvV6AJIIb6swGykDSQ4QggpYuHoXl/KHO4zsb/J8O+ql7sBhjLFD3BahcvTNJEV3JVJFav/wsqF4t76zAvfWX+3OfobbF6oL6GGFsvd+q1709osHVziX+Qxqm6q9fGXbSF/AY1XixhIaXAvD+VYk5dXlyYf95NssC1jR3s3iy+pBnukawNi6g8oxMvk331iSGzNFvL3i9Rp7IAJDM+qw7spwbx3258v6M6lb2Z7kxQjdtJxabAMV/STcUZUi1ToszN4fMePzruDEWM6QrUpy08Tc3ZXI10V7vfHpA3VjinJkBWDQ=; 5:Lofa2zFjiXcxn/7HMNga+GY5+gsY/ZBmvmVsTNxaONCPQrK15JIWkhg6QJ8gt56BCX83oAue+BdWd6kIpcq5ioKtgi7jbLYnqjb56cbk+65i26lByS/x468iChNYWBW+49wuedBPJsncnoQotiqCyDN0dUbt/JkKhufFKK2RioA=; 24:aF2UEocAB4kn5t1guhl4LOXfxLUFDVtpFGCSnU4YxX7SH/KKeVbDeTH/pWUmreDAJaHzvYloSDuC7cIdLQLjQ3cc5pL8EBKkW6+IR4qIN50=; 7:uTVEVajj7mU+O3IDO7BtwVPwfpv4OnQI3z0Yhgy8tdR190H+2E6PJ5aE86QUhjpHnl8ROdb/qxlouWyqdBuKLieAx0GibPjKGEiVAzHCSs2sx4lb1Qf/1+vtA1lot3BjsrXqfVVg3hGbvUK6yKsMKYDhnbJfuT6T3W7wVmBOwGJTddRw+FUdLExxwQumKLT9vLz+B6+rcO3NnA7ajyEnQbsHF9cJAxUA1ASnbmSZff8RkKohJ5hVQMgIrD1FGJUs SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BN6SPR00MB03; 20:PtEuNe6/VcDLhvTCsQqlYAKEtR+fJXNX9HekqAaY9BF/61yrAAkgalb0ucc0SkgYXJ2kuE4tYinAjroHEVMUelcg/nzUfM1o2F+akMo2toaOPjup/3eGA5bjsrPh56fBWIGJoclTmeO6RImxW8nfqnnMUQdAVNB/X3KyS2PmqKYTFTYuBeVQ2QGp4DIAKhEhKGOyyGXlqJUkNrrx+T1XkP/w+NIW1vZdTr3I5IykkmFl8ilv/Yu2B9/iuvTOevSI X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Feb 2018 09:06:25.2324 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7572c724-9315-4a29-11df-08d56ed33b43 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: BN6SPR00MB03 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 set TTM_OPT_FLAG_FORCE_ALLOC when we are servicing for page fault routine. for ttm_mem_global_reserve if in page fault routine, allow the gtt pages reservation always. because page fault routing already grabbed system memory and the allowance of this exception is harmless. Otherwise, it will trigger OOM killer. the subsequent patche will use this. v2: keep original behavior except ttm bo with flag no_retry Signed-off-by: Roger He --- drivers/gpu/drm/ttm/ttm_bo_vm.c | 6 ++++-- drivers/gpu/drm/ttm/ttm_page_alloc_dma.c | 1 - include/drm/ttm/ttm_bo_api.h | 4 +++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c index 716e724..f10b8a0 100644 --- a/drivers/gpu/drm/ttm/ttm_bo_vm.c +++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c @@ -224,7 +224,7 @@ static int ttm_bo_vm_fault(struct vm_fault *vmf) cvma.vm_page_prot = ttm_io_prot(bo->mem.placement, cvma.vm_page_prot); } else { - struct ttm_operation_ctx ctx = { + struct ttm_operation_ctx ttm_opt_ctx = { .interruptible = false, .no_wait_gpu = false }; @@ -233,8 +233,10 @@ static int ttm_bo_vm_fault(struct vm_fault *vmf) cvma.vm_page_prot = ttm_io_prot(bo->mem.placement, cvma.vm_page_prot); + if (ttm->page_flags & TTM_PAGE_FLAG_NO_RETRY) + ttm_opt_ctx.flags |= TTM_OPT_FLAG_FORCE_ALLOC; /* Allocate all page at once, most common usage */ - if (ttm->bdev->driver->ttm_tt_populate(ttm, &ctx)) { + if (ttm->bdev->driver->ttm_tt_populate(ttm, &ttm_opt_ctx)) { ret = VM_FAULT_OOM; goto out_io_unlock; } diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c index b122f6e..354e0e1 100644 --- a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c +++ b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c @@ -944,7 +944,6 @@ int ttm_dma_populate(struct ttm_dma_tt *ttm_dma, struct device *dev, i = 0; type = ttm_to_type(ttm->page_flags, ttm->caching_state); - #ifdef CONFIG_TRANSPARENT_HUGEPAGE if (ttm->page_flags & TTM_PAGE_FLAG_DMA32) goto skip_huge; diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h index 872ff6c..2142639 100644 --- a/include/drm/ttm/ttm_bo_api.h +++ b/include/drm/ttm/ttm_bo_api.h @@ -278,7 +278,9 @@ struct ttm_operation_ctx { }; /* Allow eviction of reserved BOs */ -#define TTM_OPT_FLAG_ALLOW_RES_EVICT 0x1 +#define TTM_OPT_FLAG_ALLOW_RES_EVICT 0x1 +/* when serving page fault or suspend, allow alloc anyway */ +#define TTM_OPT_FLAG_FORCE_ALLOC 0x2 /** * ttm_bo_reference - reference a struct ttm_buffer_object