From patchwork Tue Feb 6 09:04:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "He, Hongbo" X-Patchwork-Id: 10202507 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 761E0601A1 for ; Tue, 6 Feb 2018 09:05:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6CE3E28ABB for ; Tue, 6 Feb 2018 09:05:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6029628AC3; Tue, 6 Feb 2018 09:05:46 +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 C9A3828ABB for ; Tue, 6 Feb 2018 09:05:45 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B583189D5E; Tue, 6 Feb 2018 09:05:44 +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-by2nam03on0088.outbound.protection.outlook.com [104.47.42.88]) by gabe.freedesktop.org (Postfix) with ESMTPS id A6A4889D3E; Tue, 6 Feb 2018 09:05:42 +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=hs/T0h3aqSpcsK10VZtBu3/2RIDJ34yghOklqAfWIa4=; b=ZJEDTwrvRiennlK0nKHQlgeeOUePaJLIGbGSkDyrnYNFrhxN+NS8Dec9EzidVx/F4KHl22hv8v+bIhBbgNZD5EjCVqQUhU0Xc+Lzy90ra1eKBHiYJ1XcnThQpL4u31KhoVgCUisS2gEF63eBJoQtJ5U0yRLxlWtpv7k5rueSAh4= Received: from MWHPR1201CA0022.namprd12.prod.outlook.com (10.174.253.32) by BN6PR12MB1443.namprd12.prod.outlook.com (10.172.24.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.464.11; Tue, 6 Feb 2018 09:05:40 +0000 Received: from CO1NAM03FT015.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e48::200) by MWHPR1201CA0022.outlook.office365.com (2603:10b6:301:4a::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.464.11 via Frontend Transport; Tue, 6 Feb 2018 09:05:40 +0000 Authentication-Results: spf=none (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; shipmail.org; dkim=none (message not signed) header.d=none; shipmail.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 CO1NAM03FT015.mail.protection.outlook.com (10.152.80.167) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.20.464.13 via Frontend Transport; Tue, 6 Feb 2018 09:05:40 +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, 6 Feb 2018 03:05:37 -0600 From: Roger He To: , Subject: [PATCH 2/5] drm/ttm: keep original behavior except with flag no_retry Date: Tue, 6 Feb 2018 17:04:31 +0800 Message-ID: <1517907874-21248-3-git-send-email-Hongbo.He@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1517907874-21248-1-git-send-email-Hongbo.He@amd.com> References: <1517907874-21248-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)(979002)(396003)(39380400002)(346002)(376002)(39860400002)(2980300002)(428003)(189003)(199004)(4326008)(77096007)(110136005)(186003)(336011)(68736007)(316002)(54906003)(81166006)(8936002)(50226002)(8676002)(81156014)(51416003)(7696005)(16586007)(26005)(72206003)(478600001)(86362001)(76176011)(59450400001)(104016004)(106466001)(305945005)(2950100002)(48376002)(105586002)(53416004)(5660300001)(36756003)(47776003)(2906002)(97736004)(356003)(50466002)(53936002)(6666003)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6PR12MB1443; H:SATLEXCHOV02.amd.com; FPR:; SPF:None; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; CO1NAM03FT015; 1:Up2DSefPRbl+jc0FZpds/0a6JY7JeZ59o4XKlaNfK5QyYKFxvgrk9uXHyRTF5yPnmE7EkAKtB0piFOpja3cBbaxAUrZCZHfRJYStVIcUKsr2Mia0kB4/lF0uwJl9Ra5m X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: dafb21af-9f54-482b-bd40-08d56d40cb81 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603307)(7153060); SRVR:BN6PR12MB1443; X-Microsoft-Exchange-Diagnostics: 1; BN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sAn+Jo3ktU7Hq141VVMrNe/HnCrjGNY1Q8+xy/5Gbg6zEO6s/V09mHy5MFckjh+9QmXNG0vNIBSjY5IMKdeulyJiv3sIAKn+8a7xf4U6iIHta5LlCyVgUSu5pHd9bX3EePdQpQS5oRpDsrlQ10bpx1IrE01vIcFgkty2P09oDrkyCcyhJJgUPS8+VLTyfKAtwkn5rznAEoAVORdMO1DtTLitc69vUS4jjRt++NFC7IuZRSGiMK+BnWfZe9JH8hc3G1JPHZKGMBuMLJ7CNKjunxqUOd2ahl+W2Kt4eaui6pimh7zUX3FL2Wud7jBvB+l+2sI1iVgVrXHh7O6ZKk0Nh6QBdKTVv2awdSZiiUdZGawkJZLf4yrhFTRSB3gNx2urftx/+ocSOsBcL/y8Qw7ZUieRIZQpDmn9EwPlRuzaxZTDnrfQR4qrKnOpL8aj+ikdAsfL1zkuNWlSo9EC X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040501)(2401047)(8121501046)(5005006)(3231101)(2400082)(944501161)(93006095)(93003095)(3002001)(10201501046)(6055026)(6041288)(20161123564045)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(6072148)(201708071742011); SRVR:BN6PR12MB1443; BCL:0; PCL:0; RULEID:; SRVR:BN6PR12MB1443; X-Microsoft-Exchange-Diagnostics: 1; BN6PR12MB1443; 4:B0pNvLPU5Yjy7qUtSxFby9xq0YlpIKACHyK2LrDHmDymLyGA5i2QBNxfdEyyD0y5tA1X7a7egC0kyIV0nrgxdrAygMFX0OFv98hHZHee5ikLV2e8sB95T6ldlKJw6HVvlMxrLpYk4obzE16v0B6XMVNqLVeZMp6Q2errDX5z2i5DOFV2Vj2dEwDtrRGl64n50zRhvMHWo5UkGYaJMCvyirQplZm9UbuZeY+ssaaxfq+boZg3HRNYzjp0MYTMf3cfPCgGc1OSz8A3Kc6oomBIXYWTtMKn5KuPmNFfPNQOFf0rZ/KcxzrQ32qvnazJeRxU X-Forefront-PRVS: 0575F81B58 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN6PR12MB1443; 23:IIa1aw8Lh3NfxyE1zqGAh94Az3La+X1kOSdE/HQoU?= =?us-ascii?Q?KWp0beslL51mjjs+l9hrS5VHIGtmJkDmccVAinOeqILQlSRiMjsdgJ59AnpP?= =?us-ascii?Q?haMrYN8x3tcyHfw8Jbesic7CEQqv7VDd2c0c3dX7S5QdQfQFlA+dGpGZbDFZ?= =?us-ascii?Q?aF3nTMVb60/aC4LPLDYMx75kDPFjuQDyVjVS/2pskQd153CNgDSOApObgQ62?= =?us-ascii?Q?0sjeNL2LLFva7PLhkeDJmIOyBvPh84v08xhIHvtX4IbQTzTTgHmAcXQ5Bwrt?= =?us-ascii?Q?H7TztBy7Z3lr4Eagfp58Sw6ujUkxRyI5XBRWvhEM4jdW8Tb0YnrE34XjT5cI?= =?us-ascii?Q?+v8/uweqBdyrPQYmElJwbrTOuj+BpfqARqXCc++WuJQIpo4NxELX+EHb4gWJ?= =?us-ascii?Q?QoH4ossz8ikRYg2gE8dZyurpb/D3LIMUtV+RzeIwq2ALj9uP51qmA4qw5mi2?= =?us-ascii?Q?vps/Bkb6MgbLcTj87G4i7FEtbzGCp5sBSEfI78Np+3WeLwrUKYsIGYHbSo28?= =?us-ascii?Q?LJCPQTXKwd6NVkAIILmLBKY/KGGjEHbIJYCUwFVEmK1l6N5nAY/vnMZrKEtw?= =?us-ascii?Q?PSq8y46Qtg1FvYOLiWCBANZi6OSz1XSIk6I+yI2YvMW2kXFwlIL0HY5oVxD3?= =?us-ascii?Q?gRbcokzi2l8LX4103Jn6EAj4slt/BFX10dezfOr60BtVPsXvgDAxTk8/xbB1?= =?us-ascii?Q?Y3ULJMgKNiwIKkXJn5xos1FcYT88S68REzfj0oFGLNECGIbCexXE3zdv0mmM?= =?us-ascii?Q?fDOTeC2VDJj/GCXYjh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pT1Dfa/unJZOFe5waiTjku/m9H6wqVKIcjCBw0=; 24:EMK4Z0fVpbtvJtxWCjss4xHP2SoNZJw91EG18uKxl8h4VmeU4B/zB2ztwz7tSMjoIoYcwsGGKvCW+aaJ3FJYXa6wwtrTy4fJ7QGYyGJ9wB8=; 7:098lY/UW3jOI4CCT1Sqtat0JQFOVONBkeqTthSVuaA5E2O6yqJD25iLZbBA5w6Y/KD3wuPZFr5IBtzH2WqqTwI00IJV5P3ndBD0UmV1gLFu5tJ7Fff7Kdpjd9V/XTlgo7DEDuLegf7c27nYGM65muk94k9OIay2DTMtooyjAsliPnB55+wIMEHVZ42N7wX5ypE88i677npSa5upT7nhW6hPdnBJ45+fdLtALO+VZUHIgxfc3gQK7K5hIqhWQ4z14 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BN6PR12MB1443; 20:Nlw7dEYBorN/OiX0Md6Ly3Le8/uySdUOOTfa3Xlv83PkRgFHzIMOE2e/7s2SFpG1W8W42K4EXG2mAS16UHkM0C4+58ZgHbehf3ICxSzqUM5TfeGzt+CM/wKGgHamUbZme6DfQzX0ozZnHR9r1iIngMWh5bz1PLcUCbVoYhUwFi15fkhmBHRb1H2ZYvYpka+9xvNOMtgKhLrzp+uqFgzqiKbMebE8XML7doaVPX/SIQY0Zm2Z02QCQ7KcbUaIVRlz X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Feb 2018 09:05:40.0530 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dafb21af-9f54-482b-bd40-08d56d40cb81 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: BN6PR12MB1443 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 the no_retry flag in struct ttm_mem_global and init it after ttm_mem_global_init Signed-off-by: Roger He --- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 8 +++++--- drivers/gpu/drm/ttm/ttm_memory.c | 3 +++ include/drm/ttm/ttm_memory.h | 3 +++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index 95f9901..f740248 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c @@ -75,6 +75,7 @@ static void amdgpu_ttm_mem_global_release(struct drm_global_reference *ref) static int amdgpu_ttm_global_init(struct amdgpu_device *adev) { struct drm_global_reference *global_ref; + struct ttm_mem_global *mem_glob; struct amdgpu_ring *ring; struct drm_sched_rq *rq; int r; @@ -91,6 +92,8 @@ static int amdgpu_ttm_global_init(struct amdgpu_device *adev) "subsystem.\n"); goto error_mem; } + mem_glob = (struct ttm_mem_global *)global_ref->object; + mem_glob->no_retry = adev->mman.bdev.no_retry; adev->mman.bo_global_ref.mem_glob = adev->mman.mem_global_ref.object; @@ -1371,6 +1374,8 @@ int amdgpu_ttm_init(struct amdgpu_device *adev) int r; u64 vis_vram_limit; + /* We opt to avoid OOM on system pages allocations */ + adev->mman.bdev.no_retry = true; r = amdgpu_ttm_global_init(adev); if (r) { return r; @@ -1388,9 +1393,6 @@ int amdgpu_ttm_init(struct amdgpu_device *adev) } adev->mman.initialized = true; - /* We opt to avoid OOM on system pages allocations */ - adev->mman.bdev.no_retry = true; - r = ttm_bo_init_mm(&adev->mman.bdev, TTM_PL_VRAM, adev->gmc.real_vram_size >> PAGE_SHIFT); if (r) { diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c index e19e727..3f00ed8 100644 --- a/drivers/gpu/drm/ttm/ttm_memory.c +++ b/drivers/gpu/drm/ttm/ttm_memory.c @@ -488,6 +488,9 @@ ttm_check_over_swaplimit(struct ttm_mem_global *glob) { bool ret = false; + if (!glob->no_retry) + return ret; + if (get_nr_swap_pages() < FREE_SWAP_SPACE && si_mem_available() < glob->sys_mem_limit) ret = true; diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h index ad7cf63..7fee446 100644 --- a/include/drm/ttm/ttm_memory.h +++ b/include/drm/ttm/ttm_memory.h @@ -56,6 +56,8 @@ * @zone_kernel: Pointer to the kernel zone. * @zone_highmem: Pointer to the highmem zone if there is one. * @zone_dma32: Pointer to the dma32 zone if there is one. + * @no_retry: if free swap space is under the fixed limit, no retry for + * avoid OOM * * Note that this structure is not per device. It should be global for all * graphics devices. @@ -78,6 +80,7 @@ struct ttm_mem_global { #else struct ttm_mem_zone *zone_dma32; #endif + bool no_retry; }; extern int ttm_mem_global_init(struct ttm_mem_global *glob);