From patchwork Tue Jun 22 16:23:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrey Grodzovsky X-Patchwork-Id: 12338009 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B232C2B9F4 for ; Tue, 22 Jun 2021 16:24:12 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3654C60238 for ; Tue, 22 Jun 2021 16:24:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3654C60238 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A8FCA6E107; Tue, 22 Jun 2021 16:24:11 +0000 (UTC) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2056.outbound.protection.outlook.com [40.107.237.56]) by gabe.freedesktop.org (Postfix) with ESMTPS id F2A7F6E107; Tue, 22 Jun 2021 16:24:10 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=J4SaaVtXKYmmNVm6lFFfZQ1Pf0vT8dq1r9pBG6wgU4NnHIfJVqeIqDnTxxS3G37lLdnREgtRc7+5TiKUhjAx8yJwjGNWGfYFs+dqz9wHkhWVcXdl/wpxbIQWTUhqXWGDU4zKUlHdI4Ii5n/hlKu1j0jYFJn5T/5C6uozk59cKwfTqNVIWB/pSOwm9d7oMhAj8p1xVqpVk3+8mJVD0wKt/pJa0LiCWIn5koiipW9mGK33qEPfi1icHl6ZmDXCTiLC4G2ouX/2IVHZmqavKZh+FC4N89Y+W2nOe7OL5AowSjbsTZOsxVT8F9YOJiA8XYcC51t1XeaNxbRBbXZ8CcUM2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=aeq3lPKpic4GpmDjUD2jzgFHSzvPxEwBEV1xsFKCcIY=; b=exy5ssp/0JWXqDeovR5ee6ceIBaAWf8fUNarcwF3JPDduDVcUaltCB6vhYphYHdibh7Xr55tcn/dgrQxN1lkZfwF5CR6qG9wKifuvd0Az/rcVjPrKbHHFOy8P6sX90yuftm0SMuaye5a+/4KXJQYWpnDk1OT1hw9+tPNePUhBSBDzAdncfPthX3ltNNfbRFo8Vuv+tfnBpLcWJ+o7Eq02EcR1Y2wjRNj9nn3cMxQZxnM3bVJW5EAJPnBOGGFPYmIXQ0VGt9jgGarnG2RFOBD8ZMepvWGclTmxWy+m3dWdODbJu4BjbeDsYlgJBHFq9St7HvgNJLBPxea5OarG5p+UA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=aeq3lPKpic4GpmDjUD2jzgFHSzvPxEwBEV1xsFKCcIY=; b=hFZrPbXhA8FTF54Y4kH+hke2q3pQEVcGwDDsCdqGwCvEvo1DLJX8yAHQmyWW8nCF810tsZB5+9UOBQ792SWkGYA1BYbdWp/6cGCPU/JcIedVUiw3AEN/XO5x2zJwlKoZRk+LYbfxMChaENAn0mtyny/K8Z1wWsasL5CZinJKWu8= Authentication-Results: lists.freedesktop.org; dkim=none (message not signed) header.d=none; lists.freedesktop.org; dmarc=none action=none header.from=amd.com; Received: from SN6PR12MB4623.namprd12.prod.outlook.com (2603:10b6:805:e9::17) by SA0PR12MB4399.namprd12.prod.outlook.com (2603:10b6:806:98::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.18; Tue, 22 Jun 2021 16:24:08 +0000 Received: from SN6PR12MB4623.namprd12.prod.outlook.com ([fe80::9f8:ec71:6535:cd36]) by SN6PR12MB4623.namprd12.prod.outlook.com ([fe80::9f8:ec71:6535:cd36%5]) with mapi id 15.20.4242.023; Tue, 22 Jun 2021 16:24:08 +0000 From: Andrey Grodzovsky To: dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org Subject: [PATCH 1/6] drm/ttm: add TTM_PL_FLAG_TEMPORARY flag v3 Date: Tue, 22 Jun 2021 12:23:34 -0400 Message-Id: <20210622162339.761651-1-andrey.grodzovsky@amd.com> X-Mailer: git-send-email 2.25.1 X-Originating-IP: [2607:fea8:3edf:49b0:5c6b:dde9:a4fe:685] X-ClientProxiedBy: YT1PR01CA0137.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:2f::16) To SN6PR12MB4623.namprd12.prod.outlook.com (2603:10b6:805:e9::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from agrodzovsky-All-Series.hitronhub.home (2607:fea8:3edf:49b0:5c6b:dde9:a4fe:685) by YT1PR01CA0137.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:2f::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.18 via Frontend Transport; Tue, 22 Jun 2021 16:24:07 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a79ec498-aff4-41c3-d186-08d9359a2905 X-MS-TrafficTypeDiagnostic: SA0PR12MB4399: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:590; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: g4X4yJkgkyBznOOHc3pW6fusIWob1tJuvP0Zsq0TTB9d97CAVTmDHMBGjxGRsiq+o5oOc4Cr2d2oO4ujHlPDc8tk4GDRIU36luZ1RAZBPVf1ii5lSc1sHQ2JidQ1NfdmRHBi8DmB4aCuL0rhthz4WK10m0ebum5jRjdJEW7zFkb/W8LH4MHI6c/mZLGAO4lsZ5HeIRoXd+MG0k21AGXscRSahxzh+ZEpnjkrUKUXDgvhwMv2dQAdc8Gb+DOGtg1O7qsFZGamwRY9WG1lUhMebnmvPIOWKWhDWs3hMiC9h6ZUtlxSXhrZ22d9OuEHF/NNr9ShTj3S6QLTVcSK0YKJZgahfqF3JyHhxeczngfuM1Mx5YevEzqSr5h/tjvicoZqlEncFnF1pTEBGAz2Kcy163hL2jOebsCRChcaLXAzp+4g0Lfm3eftERsaiI6XLUtwUmdWT67v2MUTfNUcOiZIHmn8aOsrnDNSYEkKqC0hpPNnN1a+7tdOhz4rmBpRnQ5h4m7NwV1fexZhHVAuIhHGWroQw6/UfiIu+4rUri9SZIuAX0vBQ4JKkYqqEr6Ezd0JnKJCXW9YoK3Su5AUq+RYFb6BBKHHnZtwhtcKRE9Dors= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR12MB4623.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(36756003)(66476007)(66556008)(66946007)(2616005)(44832011)(2906002)(8936002)(8676002)(5660300002)(6666004)(86362001)(6486002)(16526019)(186003)(66574015)(6512007)(6506007)(83380400001)(1076003)(52116002)(38100700002)(4326008)(498600001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?Ff7tuhwuIJBThmtWATFw3FBKlAcC?= =?utf-8?q?FRW01AahpYLwqwYkg4q3lXSeyo4pOPiUsOSRxWt/yoQWqe6sp+Y1zrzhsy4NihW2Y?= =?utf-8?q?+r8UUj7yBJGgsXpwGMv1nxyTsKcOFS11FaV8/s1/h6XWGFTMphSvficwCZnPNMLod?= =?utf-8?q?3tKPHuVktFOh2P7c6R8cgeaft6H2V3LZYxI5Y2MC2wBDqlvKwWxFpryFjzQx9vwST?= =?utf-8?q?2hpBDNzUG7IiVqw/vvRkICi/bMiyORI1BdqrUc8FdCaLJzI6+h5ctqTo1jjddq30u?= =?utf-8?q?XhXPKlg2tZTCpOY6MXrn3vUEy3fVX+sNzbLSoj7zqX4pSFqQVDW2CmD76e6/N0TS5?= =?utf-8?q?OPAKI0uY1q4rdohWvxbt1p6R6A7X2fLSwtyUNWgPsbkV8T+H47w3BlNgFKd9xiF40?= =?utf-8?q?wG8Kj6+1UBq9F0RtdN8rJpnvAiciZfBkrsGvXUvBcqo4UdhIV9oF4Uaa8yiO3iPv1?= =?utf-8?q?MRSs79MO5jwJ1Jlogp5a3K9hTbPe+c2D2fmUXHAPvlZBffRXyW2COXI9piLIVX3DV?= =?utf-8?q?FKtG96lvJqHW2ktIuKMyNJhKIoU1D6DCzOanfE15PLiH18Tna2BcwduHbfoYFncX2?= =?utf-8?q?efmrPegdSlbm0pOrlOcISb1f5EEOXPsxfGsOmR4mgH+PR0dd6J7t/DErWWyOGEn+z?= =?utf-8?q?+oegktOzHpEGbObRQZuEa2yrwiCM9tCOtp1Byf1reUuBtBKxa8GE/r72Sw13MOcZA?= =?utf-8?q?pQJ0b6uU3StqSL7W6IaRnIU9C9TxfD/8ck79fBxgdvQ3Z9wjqymmcXoVRbCHP3bgH?= =?utf-8?q?+kkwBPp5883XG8nSUTHqsUMCjWH9l1qafGwUwkqrW5E8IY8XswZEmRuDHLODJ/2b8?= =?utf-8?q?nfuzPNuH7mtm8y+/oT11UafbCHIueN4NovblcrPLAUI1W9mpWLSMRVC+Ok+54SMBr?= =?utf-8?q?Bcr1iJmBHMWiLvCBsh6AdjeIZt3FqWb4d2571g7qUCc6ek8Y3npC117ajmYSJHxSE?= =?utf-8?q?OD1OAZ8zpdFo0xCXbvShtje2oCZ8rOcf2k8eaXkke5CsZUODk3uE+UgsJ3OmeG13i?= =?utf-8?q?K4ciAKZ0/PYfPhh7dmAdyd4XIwFRGRCio61eeHdkEhbksjCUEZL4K9VbOEpBNzxNK?= =?utf-8?q?I/oUUBc8vRsnhc85CbPn0r2EWVn0VkO0DIAhdcqhmfuqkgDkTQU7BZaiZC2hxGc1u?= =?utf-8?q?JzH83IeJdxnZBbEr21eWh7/xu4IEjQsJpWNEkyWRWakDFPwjJZuty3IGe+mgH40pu?= =?utf-8?q?2bPoZKX0sfVeB0FLt1j5CpuJQFqWTIPdngezsoM9/7WNcBXcU7H2J+w2qXhdNMZ/6?= =?utf-8?q?8HJuafXGu0mfxiAbPw6dY9J/IXrjmHE9Qmojq2Vt3mvZ9OvzMsNGVF7ZfVOtOx9XF?= =?utf-8?q?I68X9yzQErLdJfa?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: a79ec498-aff4-41c3-d186-08d9359a2905 X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB4623.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2021 16:24:08.1597 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: VJGLOcKiG2JIKgCNa6891UrNx0B20UPdlg7W7xPCtpX6vLO5Z+zD2ZyOjK2CdaqKQ0iBfYMKihAkJZS6YI6Wyw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4399 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ckoenig.leichtzumerken@gmail.com, Lang.Yu@amd.com, =?utf-8?q?Christian_K?= =?utf-8?q?=C3=B6nig?= Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Lang Yu Sometimes drivers need to use bounce buffers to evict BOs. While those reside in some domain they are not necessarily suitable for CS. Add a flag so that drivers can note that a bounce buffers needs to be reallocated during validation. v2: add detailed comments v3 (chk): merge commits and rework commit message Suggested-by: Christian König Signed-off-by: Lang Yu Signed-off-by: Christian König --- drivers/gpu/drm/ttm/ttm_bo.c | 3 +++ include/drm/ttm/ttm_placement.h | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index db53fecca696..45145d02aed2 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -913,6 +913,9 @@ static bool ttm_bo_places_compat(const struct ttm_place *places, { unsigned i; + if (mem->placement & TTM_PL_FLAG_TEMPORARY) + return false; + for (i = 0; i < num_placement; i++) { const struct ttm_place *heap = &places[i]; diff --git a/include/drm/ttm/ttm_placement.h b/include/drm/ttm/ttm_placement.h index aa6ba4d0cf78..8995c9e4ec1b 100644 --- a/include/drm/ttm/ttm_placement.h +++ b/include/drm/ttm/ttm_placement.h @@ -47,8 +47,11 @@ * top of the memory area, instead of the bottom. */ -#define TTM_PL_FLAG_CONTIGUOUS (1 << 19) -#define TTM_PL_FLAG_TOPDOWN (1 << 22) +#define TTM_PL_FLAG_CONTIGUOUS (1 << 0) +#define TTM_PL_FLAG_TOPDOWN (1 << 1) + +/* For multihop handling */ +#define TTM_PL_FLAG_TEMPORARY (1 << 2) /** * struct ttm_place From patchwork Tue Jun 22 16:23:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrey Grodzovsky X-Patchwork-Id: 12338011 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 30851C48BDF for ; Tue, 22 Jun 2021 16:24:19 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F00D260240 for ; Tue, 22 Jun 2021 16:24:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F00D260240 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 481D46E5BE; Tue, 22 Jun 2021 16:24:13 +0000 (UTC) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2069.outbound.protection.outlook.com [40.107.94.69]) by gabe.freedesktop.org (Postfix) with ESMTPS id C65F26E2D5; Tue, 22 Jun 2021 16:24:11 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jzIuBSXLYkqKXyFcs+KekZ7oMkMfA2K1PnDyzj0FtMgoknGzoEvACzQQbNz1w0u7rOw+rsUCxtJywNmirDU4vPY19oM6C1QhTX0biZ1cC6vWsOhzkVyL1zydYs7NEeVt2n/5IQ3O95rtsioZuWJ0wllObPcFkd+134eUBO0zl2NQzLXY+SXx1wKIuI1LdsQ/CVISepz9duBWoe8zk+jtDARp6G+1RvbU6LHrfQdbFQTmpkDC1sZKGmbtFv0eADQ/1nBtheah2F//fTtkcrRI5h5CLLruxxKTAVcN7G/9YQS/12H+rcbV+NSp9YkmaPgRVOe5GZi2zc+fmib4UNeDxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=cIlbrlBQPhwCCtEJn+woubiFNTaH47GxA/pBqNMl0l8=; b=dm1UEVOcTvsteDvnC35SQ3yte3mkkvs3nPqZCgwHjWMUrJfEtwSn8wAQXL4gPxe2S33ib/y/LJVqtTxICQZdGo9jQA1C2J3JQb9kV1vP0JwoHiUnsf8m8yba09xtzMSQl1dHxdhmre8FyB5CnyYTYcAteqmZhTRT+AF7JfWENvbkef9zmfRP4EBLkvGV6JyrTqYd0E0HTx2s7tnRIaFXAG/uqJ0mTmsxamI6YOK9fd4fcCxnspT0/o68qcmX3A1RFyD4Y/idJ5MIKmGwRkSwfeqKcBZoxy/xgX7lGKraNBDJc+MgYYLGz+uPnKWKHT/JFu/mIPkarZ5AnjuSBkBtwQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=cIlbrlBQPhwCCtEJn+woubiFNTaH47GxA/pBqNMl0l8=; b=5Rw7pl8O4ecEHM9R5e63aJYlhjaJ+Bx6+FMInjyN8w3BLxmSIjYkRZHDiAEcoIWABFCcmf29EXyRCM2LE6gSDEjqe5hEGXTgbvnl6YKK9ZNgb6mKlzrrdICPHdpGbtS9sPFPDtBxRzHh/PzD65ZWopbMeEBcmMkw0ytjRWao8g4= Authentication-Results: lists.freedesktop.org; dkim=none (message not signed) header.d=none; lists.freedesktop.org; dmarc=none action=none header.from=amd.com; Received: from SN6PR12MB4623.namprd12.prod.outlook.com (2603:10b6:805:e9::17) by SA0PR12MB4462.namprd12.prod.outlook.com (2603:10b6:806:95::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4242.18; Tue, 22 Jun 2021 16:24:10 +0000 Received: from SN6PR12MB4623.namprd12.prod.outlook.com ([fe80::9f8:ec71:6535:cd36]) by SN6PR12MB4623.namprd12.prod.outlook.com ([fe80::9f8:ec71:6535:cd36%5]) with mapi id 15.20.4242.023; Tue, 22 Jun 2021 16:24:10 +0000 From: Andrey Grodzovsky To: dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org Subject: [PATCH 2/6] drm/amdgpu: user temporary GTT as bounce buffer Date: Tue, 22 Jun 2021 12:23:35 -0400 Message-Id: <20210622162339.761651-2-andrey.grodzovsky@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210622162339.761651-1-andrey.grodzovsky@amd.com> References: <20210622162339.761651-1-andrey.grodzovsky@amd.com> X-Originating-IP: [2607:fea8:3edf:49b0:5c6b:dde9:a4fe:685] X-ClientProxiedBy: YT1PR01CA0137.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:2f::16) To SN6PR12MB4623.namprd12.prod.outlook.com (2603:10b6:805:e9::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from agrodzovsky-All-Series.hitronhub.home (2607:fea8:3edf:49b0:5c6b:dde9:a4fe:685) by YT1PR01CA0137.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:2f::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.18 via Frontend Transport; Tue, 22 Jun 2021 16:24:09 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 39e8f2a5-0b89-44f6-3f23-08d9359a2a32 X-MS-TrafficTypeDiagnostic: SA0PR12MB4462: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5236; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: l95BeDMYyx22SoNxA9JHF5gWTpbJixZccbDJzLJQVQBUxiR5MyBj1Sj5QG+iwu5lH6iUaLN1bvKACxTvo+gFPJtolYgH+b7ZUG9sYHY0AO3774O60NmindHwNSMJxVdU0i6U/AwY4yUgfO5pi4QdfsKgZUBseZpElFSyA+YzgTDweq6/U3YYT0vIj4+MQsmfP43UwB8Ngpqz35CB2FFMJIJzHcHOQjAp22ZhCmWmpuultJLFCsWZTsud8GbLI8ApaA6uB6TkE+MvYVvk+Qxsf7E8dPtrtpvgJhRTklwdlNkxwAa6QcHKnvrAO0XXPM4nGQ3SZZ78bqmzvvoA2KXWirtJcfwNgVYOOR4zMeDljZi0MCHWSHNgyN/Ss/5J7DLhCoJj+xvsViH6/4ewYIdCe7j+lYxqG5oSk2rqjUzCIsVgEZ0CqbGGUiRQ8UEDfWyOeJj2Ixj2KNqGbntAbmzVEjqTx+vLx881uS6zczc8AOq398p+JwNfJz1y64fkIx2ZQrax/eFOq28P2inyTFztSwT/Dc9OcXip0qe01jTnNQZoW/zLoYEa73VZLl7fHIH+wNxBJOkOeLnRpFEO8ewK9PEKF0tyFE8u58CuKnXKmEQ= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR12MB4623.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(2906002)(6486002)(498600001)(5660300002)(1076003)(52116002)(16526019)(8676002)(83380400001)(6666004)(36756003)(44832011)(38100700002)(66574015)(6506007)(4326008)(6512007)(66946007)(8936002)(86362001)(2616005)(66556008)(186003)(66476007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?RKO0UGR60N1ZvOlsmb0fgU8n3uS9?= =?utf-8?q?hyMuj8gfjFvpbouiwJWkJlW7eZf4BjbY19gy0aWq0y3MfBZc7zlcU5UFsRiWeWzg5?= =?utf-8?q?XINzdCo5bFcPALwpp1Nrv+eHHO3UrJoRFItfwaGM9i6q4tfXhTh/r205zw3bweJuP?= =?utf-8?q?ijxKO7cFMhHVnTjsO5EkHZk1IHB+p5x0CURM+r5Q+TzQ4EQnPSIJlIHEfT4CG3/lY?= =?utf-8?q?5fYawrnwtEjGDITEOKDihLvChfcPyD+yEJ/DDv6sIltALpNeLch3eLu0RjHRbySzX?= =?utf-8?q?53SXxy7okuGW+v1rRs8iHseWIrdk11e94gpjmsLhcrvM7VHLyr6bvSOeTpuK39zuy?= =?utf-8?q?B7V0nfFSmsX88fwoJrLNwr5GF6fUFMgACZK1eBpR5O7WXsp89nKGMY8HUfhQtSbpu?= =?utf-8?q?f34cX5AgL+lsNrh+vHtkbzrGuA0Nx3MKIG3QlHdfy/cGOuMR2F/pvoAASt+V5smMD?= =?utf-8?q?9NmalZOk428zxNVrcRvmMGn9wkap+e+Gu85PghOyOJ4W8gPQyQA8AUTjneGcrwmg5?= =?utf-8?q?bFNnWAsSjsl+4vuH50W/CdUoWuZ85izVyoGryFjSVdLAdt/e/YLehh/t/JlQ2OfC2?= =?utf-8?q?EbhLpmF6iGC2DW019YwnGO4NJ+fzH0CECr4AAZbnJZogj9Oj/NLao2kUzijim8x2O?= =?utf-8?q?6EaPqBtwG47E8iITO3e07CCfICcyoDN3Eaw7tPSY/WHxgoBnpVsTEtJypshD7DGWb?= =?utf-8?q?RJ/EkKnpXeAc1c4t6CYqdOf9hferi/8Ku4OUlYopj4rvo4FO32ojc/XJROoiD/YBB?= =?utf-8?q?vqxNQDwDxSkYDUfcwFnlzW70tpLDSvOh2KWytxJTOqJlBSyvGFp6JJQeWc8vVeIu7?= =?utf-8?q?N6hUVlkaNFvf/kPrECRC6Yscc6dQdwNXek8XGJP8aCbW6euDQ3v6kFfK4xQa4z958?= =?utf-8?q?DqFH0b8GsX6MphlmfqlcGgBOQbZRtDS9jyC9OmrsIU9xkddEuVwOIOhNepbbj+YP0?= =?utf-8?q?vdOsAT8pwNdilCmEY5QHo/5zDYc7tPKsBw4968ANCamHijwrYy4Dz8VDgPUr8EiKp?= =?utf-8?q?cNMTHSD+3DdGBZr2Eiq0C4U2Haz30IYYEYK+l/ISe5IFqxEr2qws3kYBABauYL9IK?= =?utf-8?q?l5/YveKhovbQOALA7jPBu/Z7JHMq4Mljw1vT1WXCuYAQF++JtFP24NNl0iPML6bku?= =?utf-8?q?oVmQSDdL2PI37duGTQXIceh02u8dyRbdbxp/u5IBefYMCrFZvbjlWi4HA4BJYzGDX?= =?utf-8?q?dsIXiyL1etDiaDXLfLw0XVU7GW2CmPYR/GC3p9qjb2JKVii/K1choYebNoptw6//w?= =?utf-8?q?njQq/0LIm4EBhz6dAYHFRzw1KmBP4bm571QL+Z72Fht2BVbQ5x5TBfzzKdhKxVh7o?= =?utf-8?q?wE1eZR9VQIE9rnM?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 39e8f2a5-0b89-44f6-3f23-08d9359a2a32 X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB4623.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2021 16:24:10.1516 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: D7iYFtoLMx5y/Uszr7KWBpzPZORTf7C8q9pX+1avJFSGbOiEkVfMEZqkL5uUiRP1NyS5Pd5W7RleqZVVF9ZLxA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4462 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ckoenig.leichtzumerken@gmail.com, Lang.Yu@amd.com, =?utf-8?q?Christian_K?= =?utf-8?q?=C3=B6nig?= Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Lang Yu Currently, we have a limitted GTT memory size and need a bounce buffer when doing buffer migration between VRAM and SYSTEM domain. The problem is under GTT memory pressure we can't do buffer migration between VRAM and SYSTEM domain. But in some cases we really need that. Eespecially when validating a VRAM backing store BO which resides in SYSTEM domain. v2: still account temporary GTT allocations v3 (chk): revert to the simpler change for now Signed-off-by: Lang Yu Signed-off-by: Christian König --- drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | 20 ++++++++++++-------- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 2 +- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c index ec96e0b26b11..b694dc96b336 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c @@ -132,14 +132,15 @@ static int amdgpu_gtt_mgr_new(struct ttm_resource_manager *man, struct amdgpu_gtt_node *node; int r; - spin_lock(&mgr->lock); - if (tbo->resource && tbo->resource->mem_type != TTM_PL_TT && - atomic64_read(&mgr->available) < num_pages) { + if (!(place->flags & TTM_PL_FLAG_TEMPORARY)) { + spin_lock(&mgr->lock); + if (atomic64_read(&mgr->available) < num_pages) { + spin_unlock(&mgr->lock); + return -ENOSPC; + } + atomic64_sub(num_pages, &mgr->available); spin_unlock(&mgr->lock); - return -ENOSPC; } - atomic64_sub(num_pages, &mgr->available); - spin_unlock(&mgr->lock); node = kzalloc(struct_size(node, base.mm_nodes, 1), GFP_KERNEL); if (!node) { @@ -175,7 +176,8 @@ static int amdgpu_gtt_mgr_new(struct ttm_resource_manager *man, kfree(node); err_out: - atomic64_add(num_pages, &mgr->available); + if (!(place->flags & TTM_PL_FLAG_TEMPORARY)) + atomic64_add(num_pages, &mgr->available); return r; } @@ -198,7 +200,9 @@ static void amdgpu_gtt_mgr_del(struct ttm_resource_manager *man, if (drm_mm_node_allocated(&node->base.mm_nodes[0])) drm_mm_remove_node(&node->base.mm_nodes[0]); spin_unlock(&mgr->lock); - atomic64_add(res->num_pages, &mgr->available); + + if (!(res->placement & TTM_PL_FLAG_TEMPORARY)) + atomic64_add(res->num_pages, &mgr->available); kfree(node); } diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index 80dff29f2bc7..79f875792b30 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c @@ -521,7 +521,7 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo, bool evict, hop->fpfn = 0; hop->lpfn = 0; hop->mem_type = TTM_PL_TT; - hop->flags = 0; + hop->flags = TTM_PL_FLAG_TEMPORARY; return -EMULTIHOP; } From patchwork Tue Jun 22 16:23:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrey Grodzovsky X-Patchwork-Id: 12338015 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31785C2B9F4 for ; Tue, 22 Jun 2021 16:24:27 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 067EB60240 for ; Tue, 22 Jun 2021 16:24:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 067EB60240 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 389BC6E5C1; Tue, 22 Jun 2021 16:24:17 +0000 (UTC) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2084.outbound.protection.outlook.com [40.107.237.84]) by gabe.freedesktop.org (Postfix) with ESMTPS id A9C636E5C0; Tue, 22 Jun 2021 16:24:13 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ft5rSvxSzlC+h15Ifk30bKhnmVANtaRDs7vvFshCHVzDkGlAKK1dfjWBjMlEUrNlwxHk/aMunZ9qV0eSjk2uzF/kL2zBIBEfI+xWKF5LlNsTJBl5ukxbJ5KFTIbH6HeUTEEP5/SVqYocGYhwq6/LnlaqPhtlBuQmkXsI+Vquiacd14OuLceH7kxtTibJrbThIDfCeca7+3vhLYF/cZMGdTSTEfvnlGz1dTK5PgpciKF5dtIKTYFt/qZDF4d8WresFVnuOpaewn7GYsoIxhr4F63Apb3i30y61F3SSMjg29QdUx07WLU7OtqEJ81ApkznpUJ7ihSMfdvtJ2iy5Kljeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hXsPlRN77QPW+FUwi5x4I+6OwsqiVa2abqH4ZYZ9ZrE=; b=ZyjG+gqEIQS3RssIfv+ezIq99V9hYG1+f2eRMMvEocB7K/6BbkvBnEsGDjNJu/KV6gLbEKi5CcX56mPSsY/joP7mIMeoctDTixAId1Z5imH6DWG1j2iDJj1gZ6UTulkuDu1O/ZI7WphNbYn9N/f8pOFY+hM8YpNEn+UK1EyHky7GTPzuEmzfIU+i0ISi5ynYMFQ5cQdaKw8S08Mpm2GvbZBsX4f1ChzzsGvId28lZHzf03mJpGoTuAnVjF83eiyD6SAqWJFGzHFpO2CFsNHERpnAcuCMpEOJ1PLu1Nu9kuLB8NR1aoACIL9MPvNVDJRb6veaPiyG1SoDP/mdLX9khw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hXsPlRN77QPW+FUwi5x4I+6OwsqiVa2abqH4ZYZ9ZrE=; b=CboWOGyIuEBzd2OOC4C+ERFHkrHz94Mraw59XJyC6P49xMVnHc2i0FaZTy/+4kkwdMLWuvFRjEKRleDMbohVVLeypkmHYM/mOQVxewT9MVW8bTch84hdWHsEx3mqW1UCHC6gkHWAZwyr+Dz1s5VK8p6FH90TJIXotlyXqx6NI+A= Authentication-Results: lists.freedesktop.org; dkim=none (message not signed) header.d=none; lists.freedesktop.org; dmarc=none action=none header.from=amd.com; Received: from SN6PR12MB4623.namprd12.prod.outlook.com (2603:10b6:805:e9::17) by SA0PR12MB4399.namprd12.prod.outlook.com (2603:10b6:806:98::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.18; Tue, 22 Jun 2021 16:24:11 +0000 Received: from SN6PR12MB4623.namprd12.prod.outlook.com ([fe80::9f8:ec71:6535:cd36]) by SN6PR12MB4623.namprd12.prod.outlook.com ([fe80::9f8:ec71:6535:cd36%5]) with mapi id 15.20.4242.023; Tue, 22 Jun 2021 16:24:11 +0000 From: Andrey Grodzovsky To: dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org Subject: [PATCH 3/6] drm/amdgpu: always allow evicting to SYSTEM domain Date: Tue, 22 Jun 2021 12:23:36 -0400 Message-Id: <20210622162339.761651-3-andrey.grodzovsky@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210622162339.761651-1-andrey.grodzovsky@amd.com> References: <20210622162339.761651-1-andrey.grodzovsky@amd.com> X-Originating-IP: [2607:fea8:3edf:49b0:5c6b:dde9:a4fe:685] X-ClientProxiedBy: YT1PR01CA0137.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:2f::16) To SN6PR12MB4623.namprd12.prod.outlook.com (2603:10b6:805:e9::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from agrodzovsky-All-Series.hitronhub.home (2607:fea8:3edf:49b0:5c6b:dde9:a4fe:685) by YT1PR01CA0137.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:2f::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.18 via Frontend Transport; Tue, 22 Jun 2021 16:24:10 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cebc4f23-3372-4e6f-b6c5-08d9359a2b0b X-MS-TrafficTypeDiagnostic: SA0PR12MB4399: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:826; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dfxIwalk5F5VMoSgKntOjohWwxE77GWyFrLK42kDxxYTEqhurzi0dxl+1HQIVCtOGsc0BZen14O5CUZJJjEMxqWMewYda566cxlcY1UPC3+2O1J2B9+zufD7mDUdVLDT5qNsULMDoilf/Z3RKeaI9vdmDpAiWD2fFR5ih+G72IOKqQTmxm+H4GvbTEUqxvcAKcBQQlbQmV3t0RyjpVg7s/7NhmynjhtglqOIfBahaewHkqNt/gv/xxzWIIbHUTMBIO9fr+kF5g1+x4GXQsrKitu2BK0zE1WKq9zKU6etn1xY0JyhhnchA3BMd+vRE4S64f3aXEC6XiYbPoEOnBwJn8kYJE+IyUpp8SMr7gj01IoYLFUuicQKmawOWoEDcmbpOcYAKvFu9XmOgeMejjw3vkAhxmJBsJTaPUXvzD7tULC/r5Wi0A+2RjmdVL0FnoeXNde8vnbNRCsiZIEuvPLBz+gGmf/EqrjQLpCXRH+APkMREwfNCdmw1Pfqgvfv1rI7ycf/Q/VytfwcMZzAjRhW8fIK3xFPNOOp87Q0m4Ya3CeACC4vk4rWYaqN1JXr4JoSBgXiLPjFJqhLsr9MhK3PJQ4JPMMGLIy5qnj7S52MZkI= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR12MB4623.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(36756003)(66476007)(66556008)(66946007)(2616005)(44832011)(2906002)(8936002)(8676002)(5660300002)(6666004)(86362001)(6486002)(16526019)(186003)(6512007)(6506007)(83380400001)(1076003)(52116002)(38100700002)(4326008)(498600001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?K6SrEy3LqDSLRjBBYRZkA6em7qnP?= =?utf-8?q?OF4IZXs7i1SjGXwkobl1fc2JorzOEQlW1cu3BHNAbJD/TbOGZnNoTKrmjcGoI0cWm?= =?utf-8?q?WRLE+sajYf32VdrUF417LlPJtBUiJDOHSicKSEEB1ULuGxHwrwzXoo8YAeLs4dyBQ?= =?utf-8?q?G980Rmk/y+ZEq6UeuTeYbnJ07VD74RKpwt6FBCNvRkalGivZk2c5SdyYR0yrPQx/5?= =?utf-8?q?iwekK0fnhKOSTpEt7plaRZqcraQs0sfVqmWOezH++I+GNI8HhhJBdwBsgxU1anKz7?= =?utf-8?q?unogUPvdELP+rx/LNOIM2Otfn6cTO6K03eER2TIilqUdvqFZC9A8sSbkulELYQTCr?= =?utf-8?q?pCQ1t8YYNZuIiQ8cqDcNzQkfzFsBKsH64eoH9XunF8yUht1U5M93mPbWIwrEbCFoC?= =?utf-8?q?HYha+/dzl5Auu5zYNmBS4XkzisRisouGXJH94mFNtsgPYBXo0Rim2N4Qn7WD/1M00?= =?utf-8?q?tgf9uVLEXg+3XibAgeBMjcASJSDnxnmaeCMTHF5mXg6/ndFcB7Xm8kNmrrcHjaYKm?= =?utf-8?q?8OxJvEfTFOyPzXj05MTOBCD9LH1olnCwB2QHd9do9y3o/iXr3jyPcclprZPZoTl5N?= =?utf-8?q?GddmoFm/YGdxQ+2Q1U4ElN9N88OGmeWo0X6psirt8TaqMJA+xU14nq2ZhmMUd10yR?= =?utf-8?q?F7NO3eRZ/dKyiaL7GfiEP/xT6HpJ8O2ulkiyOoFTUyxzN3YjFBrJg88lb6i7lQmYS?= =?utf-8?q?UtpXSyrAWVWCdEVj6zd3D5gAv+D0a0diRp/J5KHtpv6Gw/37o0XeWBhBB2Qgn9RZU?= =?utf-8?q?HtTICsk0YA03shucqdXpimezozpzwsH+RUqiG91XLJL8wqPfANCr1Zio3tSkQLIF5?= =?utf-8?q?ALCAENnhKaLaxMUgJj/eknc+ykqwx00ogTlKIsk8B7yZ+PF5VW2cBCROqEccDLpkN?= =?utf-8?q?xzJswV0APv3icCVS9ESMlDS1Ef4voyh+/1x4zzDyMoqrWVu6nCQ3c9KE/4/D4iXRp?= =?utf-8?q?clBhfxhJLHIkzfpoP3eId2chd2+ULknw3uP6ASfSOOilc404kYBlU6aVdgJrma+Ry?= =?utf-8?q?IoGsp88dd8xoea3e/y/ugnQq6/f03vQ9W86tbGfnhGTo7vmKt/2CX2fU90MjDdKWQ?= =?utf-8?q?J4jFf4JuQGQoa1ldIWmwogN7iLhHDRx6lrvKp+XJvFPVvQZCunKpR7HLywbOg0GY1?= =?utf-8?q?bcufpaYzUnX2nEAXkdD23Qg0JZmOHs0w8wZXI4S61KCLd1ah4xF+qhOnvaivhs2xx?= =?utf-8?q?B6TBM8u3NM80BL2dTYUexwRWdaXG1o4trf64G1sDYNVQg4J+Y0wfAV53u8bgzjn+8?= =?utf-8?q?7NU24S2bJ2ktgUhUUPFBxabgR9Ogoayxro7/zx3LLyxcdTUFdnF8UvBFKtQ2EtUVm?= =?utf-8?q?9U5kIFfjZgcKxmt?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: cebc4f23-3372-4e6f-b6c5-08d9359a2b0b X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB4623.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2021 16:24:11.7067 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Axa7N/HDGFuKLBavKBBS1vfSSvlfAVWBVvAqUM9y/nisQlbdT++k2R5HcQXI1xwZUft09bVsH3J/pOTDpwiKYA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4399 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ckoenig.leichtzumerken@gmail.com, Lang.Yu@amd.com, =?utf-8?q?Christian_K?= =?utf-8?q?=C3=B6nig?= Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Christian König When we run out of GTT we should still be able to evict VRAM->SYSTEM with a bounce bufferdrm/amdgpu: always allow evicting to SYSTEM domain Signed-off-by: Christian König --- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index 79f875792b30..b46726e47bce 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c @@ -149,14 +149,16 @@ static void amdgpu_evict_flags(struct ttm_buffer_object *bo, * BOs to be evicted from VRAM */ amdgpu_bo_placement_from_domain(abo, AMDGPU_GEM_DOMAIN_VRAM | - AMDGPU_GEM_DOMAIN_GTT); + AMDGPU_GEM_DOMAIN_GTT | + AMDGPU_GEM_DOMAIN_CPU); abo->placements[0].fpfn = adev->gmc.visible_vram_size >> PAGE_SHIFT; abo->placements[0].lpfn = 0; abo->placement.busy_placement = &abo->placements[1]; abo->placement.num_busy_placement = 1; } else { /* Move to GTT memory */ - amdgpu_bo_placement_from_domain(abo, AMDGPU_GEM_DOMAIN_GTT); + amdgpu_bo_placement_from_domain(abo, AMDGPU_GEM_DOMAIN_GTT | + AMDGPU_GEM_DOMAIN_CPU); } break; case TTM_PL_TT: From patchwork Tue Jun 22 16:23:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrey Grodzovsky X-Patchwork-Id: 12338013 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 69075C49EA2 for ; Tue, 22 Jun 2021 16:24:25 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3824F60238 for ; Tue, 22 Jun 2021 16:24:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3824F60238 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D5C5C6E5CC; Tue, 22 Jun 2021 16:24:16 +0000 (UTC) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2059.outbound.protection.outlook.com [40.107.237.59]) by gabe.freedesktop.org (Postfix) with ESMTPS id EB0306E5C8; Tue, 22 Jun 2021 16:24:14 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PeRB1fCPeOaA3fCKc81b7YZGK7hD5Qxhp2VI+i/JVCu3rjNMrDxG703I/5VwJ9EmHhYx1wpazaxFzF+aIH+6gyqrsu9DA8EEG1uv82a0M+23F/1cpXmK6dJ44P+qqTOu1ZDYM89R8aLlqR3+BmE/Db5BAWTL34/CRzEl5+MYy4inJxiUNr5/XuSlozofHuu3jK0R9Ex13gsJvX+2srhga/9IdQnQFkmTZQst5FG9+fq52c/jCm2dSesM25Es1Go9Uh58LQJnPGuRPhj2oOej1ipFVxpF+ZtiahnzPZlx+RQTQAaTHPYRcZkZ5xVNdkSRmQDOvxQ2KxuZ2OqtVnE1Qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1CaiVlPbXcMzNAIKpwZZwB1jg9zp/xGy6bWKgEEYdfw=; b=gXvH0Ra9+kWEixBR2PWBREbVU+67LATDQ5R1M3kOmnDy4OS6iSkLiz8Tq9ypa9PiyExYEVsROq3d0ZxBmuKrtKxvRy/xHA1T2xAwil+acKRlm/Y9TCKmtOXQfnFX8aYYL9lAGJLMd0rolK7OYnoZGF7JWrxwB8NxMdfqkkWB9YQIy7A5VFxNYw36f5fEHRtIEBVrXZVeDgZOoZlDMUJMBHa80dEyLjHjEEU78gYRtBScCZNoRLo99sn+3EtFcrYiJ+siB3EFl1Q14UlLc/FIcK+4YoNi9EhOB/jfC9Mq0m0HLyRSeOVSSDWH8SXESUvR3GnNdyNBwN64pIiKAgBfGA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1CaiVlPbXcMzNAIKpwZZwB1jg9zp/xGy6bWKgEEYdfw=; b=3JnNnu1ysrgUjKgCuyiabtgadEAO5bZOgyDxI7FWHitbMAXoZTGmp0EMo5QLZS6MhwqhbH9M9VzrWzpyIckmOqT6OC0LkhQir4PLaM7EcXgRzoKerwTXttjHtSIBDqHCiDSXBE4bN99CruFeXXFn3ld4fsmgt3J0lLFbTsgv64k= Authentication-Results: lists.freedesktop.org; dkim=none (message not signed) header.d=none; lists.freedesktop.org; dmarc=none action=none header.from=amd.com; Received: from SN6PR12MB4623.namprd12.prod.outlook.com (2603:10b6:805:e9::17) by SA0PR12MB4399.namprd12.prod.outlook.com (2603:10b6:806:98::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.18; Tue, 22 Jun 2021 16:24:13 +0000 Received: from SN6PR12MB4623.namprd12.prod.outlook.com ([fe80::9f8:ec71:6535:cd36]) by SN6PR12MB4623.namprd12.prod.outlook.com ([fe80::9f8:ec71:6535:cd36%5]) with mapi id 15.20.4242.023; Tue, 22 Jun 2021 16:24:13 +0000 From: Andrey Grodzovsky To: dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org Subject: [PATCH 4/6] drm/amdgpu: switch gtt_mgr to counting used pages Date: Tue, 22 Jun 2021 12:23:37 -0400 Message-Id: <20210622162339.761651-4-andrey.grodzovsky@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210622162339.761651-1-andrey.grodzovsky@amd.com> References: <20210622162339.761651-1-andrey.grodzovsky@amd.com> X-Originating-IP: [2607:fea8:3edf:49b0:5c6b:dde9:a4fe:685] X-ClientProxiedBy: YT1PR01CA0137.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:2f::16) To SN6PR12MB4623.namprd12.prod.outlook.com (2603:10b6:805:e9::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from agrodzovsky-All-Series.hitronhub.home (2607:fea8:3edf:49b0:5c6b:dde9:a4fe:685) by YT1PR01CA0137.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:2f::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.18 via Frontend Transport; Tue, 22 Jun 2021 16:24:12 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: aeb7a891-d1c4-43cd-4451-08d9359a2c21 X-MS-TrafficTypeDiagnostic: SA0PR12MB4399: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3631; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: r5DiIst9sfXYH8/aTgFULAaGna1+G4lnMsTJnDKtSGuBhBCoA1e21ydta3Cm92HLomq91jqi8lkoSWHXLSa1BGojB3pcr3LACsLBOkiuCBHwF2vKXmDmClXh9RtoDw0gIA+cYA9uTbMWyLEIp7yEJpEq9wzcKvmK/E0CQj9SZ6b02D4hckpfQ+WvIw+s1qOuYQHIJNlJn58Y78Ol1tstsYDij3H65uveQutzWdc6b33I9yZmVfJYfW0b4nS37xWqSH3s6LWT1lBFRHzhU83qqcOLMS7NSUwGaWw61Lqw49eNL5ASvv74bBpFsJzLGtC8P3fwt9QTJQuDkPR5/zvq3kimByirUdOm879Bf8Oovu8RuZuLFgJwMzProNsHmIcR+61NxAvfgo34Ic3nSGCXfmGbnlcmpIGPq3fFRylwGb6cf/SpomoNOH4NThTu6fi7h9yw2YShQpCblco3xk/zyle8DzIn3SQVPlJPj/djRl9iqF1+4PO9P1jxHrM71oVP9oRiGiIwvS6kTS5phG6iCU4f7yYcDNtnIaz/ESv+35iLbpi5LEq1602AGoJ3F9xEVO2EBuwpqCpRgde08Itwb99Z0Xu+H2C9Q3jh7QlcMKA= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR12MB4623.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(36756003)(66476007)(66556008)(66946007)(2616005)(44832011)(2906002)(8936002)(8676002)(5660300002)(6666004)(86362001)(6486002)(16526019)(186003)(66574015)(6512007)(6506007)(83380400001)(1076003)(52116002)(38100700002)(4326008)(498600001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?0cWcNeNMclDmmlXYOQJ7aEJ+2ZoJ?= =?utf-8?q?DS6SVOtLWHe1joeQo8a8kJ0HG9Dw4kb6uEWC2vUEx2RG+wT2V5SA3IkWFhsyCp5n4?= =?utf-8?q?pM2qgJhwL31kcx/UlmOZWfkzz8pNuGQMVZ9ujEs9trM64TujpHVP+1CBA71CHSRlr?= =?utf-8?q?Le/KeTtI8593E9j6vspptfodXUrtOcDuXwvu0yQR6YRZlnTsuN0WnOF8rfCtsuDxT?= =?utf-8?q?JgNEqq10J91q1Eu5xfE4Ua40hM2bShrlCKsWvHxJVN6NhKld0Yyg0FA9/tlDT6WHd?= =?utf-8?q?SP268O9zGwHkTZzufNsDYXemn30/V/tX0wBNFwdWfDwlvCHix5Ny7Hr4+4tKbs4ph?= =?utf-8?q?wvpq7RdxhDdk+k+GncQJebCTV+c5Y488Tc0Rgw82WNjg2L85Z21/HciFw4F3H1Mcm?= =?utf-8?q?QkHxNAsEabW4X+yjbLC/iQ58MqanyJr0jR9iVFzK8c/Ul9Q4w2I9nIQgxx0uQBzOv?= =?utf-8?q?ZsEPniLZdv7pTEMsQmCxp9gfVy3/Z2OqJEh89nl3Y0mAqJYByCoYZ0lFLV8wLymq3?= =?utf-8?q?BVC2nu84oSynVebggfJiL9fcepilQpqx4KKWgtG8W/wGGQWxW4gFx1f2rlHkLmHaw?= =?utf-8?q?Hz43akyeG0bHDsc1qfDEvFhNHpznp1w7lIpnJde+HmKlweNjmedlhbvClJLhD8Dng?= =?utf-8?q?1ZWIfnuHCAqD3GtTcD/0WDx1qPR10kClTFRE8K+xRujygXML5HxsydpVcrlHmtTw+?= =?utf-8?q?v9orTBUN0S+vziLwE3E7u9upH+MyrDEY19ZS0vsbL8sMj0Mx+uqzTaZ0pkDCBiw6E?= =?utf-8?q?QXX/JO/Y4aYGDKeivlhLpWLvl22tLsvHhoHmibNxBasNkDUqbTH8P/dVb+b+Y8p65?= =?utf-8?q?cHA2rOhYse9SAg7lMLX/8IVnpwwl3rbJrvuB9hhNI2xU1l6SvuMH3Y/g/bGE4m8Fn?= =?utf-8?q?SUYdZ28jT/AH9AKO/FsdMM4HlpunHxOHfV72z6d/VQ4UVXufy7WwC2INGo8cDvm0h?= =?utf-8?q?jQc9Uohsxghwi/5XD9x/HwEO2Saa6RKtSC5aZclYGZ4GrHiL7Xo6hhprqTpKWf/nn?= =?utf-8?q?w476u7et9s9hemPmWEnPqbaDlMuyqcvEugCzs3jBVOjSl3J2zGlu8romoVtYbVWLT?= =?utf-8?q?ntlwRy8ITMZAswcNMujqjqmerVHiL4DQoflFjzDdo2K2pslkptqHu8PQg2oo0Cfj2?= =?utf-8?q?e27havNytohF9m/20UUyoOmSPZxYE8D1YdvhqC7xxUpyJQoW6p9FfyGKKpE4vuDF9?= =?utf-8?q?m63P2LIVHZ76Qkb7wYZBqjuz/siWS8SonUg0SOXdCSJTc5CqGMsWNBXQHtbj8qACP?= =?utf-8?q?j2I7BlIlGqi+dl5+/BvJe0kIbXtjQW/7fuS8oWtFWcoE+DbVL45UmMJKSWnBe3nRl?= =?utf-8?q?n8dkdHi3da0szqx?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: aeb7a891-d1c4-43cd-4451-08d9359a2c21 X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB4623.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2021 16:24:13.3567 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 9kQdOc0n5sppYN9PfZqF2A7t+FwaAPtPm8Wd3n05sLz1ViAk4hY6BPQu2LdV4VHubphn2OdYuM0L1AF0a/3l+A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4399 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ckoenig.leichtzumerken@gmail.com, Lang.Yu@amd.com, =?utf-8?q?Christian_K?= =?utf-8?q?=C3=B6nig?= Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Lang Yu Change mgr->available into mgr->used (invert the value). Makes more sense to do it this way since we don't need the spinlock any more to double check the handling. v3 (chk): separated from the TEMPOARAY FLAG change. Signed-off-by: Lang Yu Signed-off-by: Christian König --- drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | 26 ++++++++------------- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h | 2 +- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c index b694dc96b336..495dd3bd4f1c 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c @@ -132,14 +132,10 @@ static int amdgpu_gtt_mgr_new(struct ttm_resource_manager *man, struct amdgpu_gtt_node *node; int r; - if (!(place->flags & TTM_PL_FLAG_TEMPORARY)) { - spin_lock(&mgr->lock); - if (atomic64_read(&mgr->available) < num_pages) { - spin_unlock(&mgr->lock); - return -ENOSPC; - } - atomic64_sub(num_pages, &mgr->available); - spin_unlock(&mgr->lock); + if (!(place->flags & TTM_PL_FLAG_TEMPORARY) && + atomic64_add_return(num_pages, &mgr->used) > man->size) { + atomic64_sub(num_pages, &mgr->used); + return -ENOSPC; } node = kzalloc(struct_size(node, base.mm_nodes, 1), GFP_KERNEL); @@ -177,7 +173,7 @@ static int amdgpu_gtt_mgr_new(struct ttm_resource_manager *man, err_out: if (!(place->flags & TTM_PL_FLAG_TEMPORARY)) - atomic64_add(num_pages, &mgr->available); + atomic64_sub(num_pages, &mgr->used); return r; } @@ -202,7 +198,7 @@ static void amdgpu_gtt_mgr_del(struct ttm_resource_manager *man, spin_unlock(&mgr->lock); if (!(res->placement & TTM_PL_FLAG_TEMPORARY)) - atomic64_add(res->num_pages, &mgr->available); + atomic64_sub(res->num_pages, &mgr->used); kfree(node); } @@ -217,9 +213,8 @@ static void amdgpu_gtt_mgr_del(struct ttm_resource_manager *man, uint64_t amdgpu_gtt_mgr_usage(struct ttm_resource_manager *man) { struct amdgpu_gtt_mgr *mgr = to_gtt_mgr(man); - s64 result = man->size - atomic64_read(&mgr->available); - return (result > 0 ? result : 0) * PAGE_SIZE; + return atomic64_read(&mgr->used) * PAGE_SIZE; } /** @@ -269,9 +264,8 @@ static void amdgpu_gtt_mgr_debug(struct ttm_resource_manager *man, drm_mm_print(&mgr->mm, printer); spin_unlock(&mgr->lock); - drm_printf(printer, "man size:%llu pages, gtt available:%lld pages, usage:%lluMB\n", - man->size, (u64)atomic64_read(&mgr->available), - amdgpu_gtt_mgr_usage(man) >> 20); + drm_printf(printer, "man size:%llu pages, gtt used:%llu pages\n", + man->size, atomic64_read(&mgr->used)); } static const struct ttm_resource_manager_func amdgpu_gtt_mgr_func = { @@ -303,7 +297,7 @@ int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size) size = (adev->gmc.gart_size >> PAGE_SHIFT) - start; drm_mm_init(&mgr->mm, start, size); spin_lock_init(&mgr->lock); - atomic64_set(&mgr->available, gtt_size >> PAGE_SHIFT); + atomic64_set(&mgr->used, 0); ttm_set_driver_manager(&adev->mman.bdev, TTM_PL_TT, &mgr->manager); ttm_resource_manager_set_used(man, true); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h index e69f3e8e06e5..3205fd520060 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h @@ -52,7 +52,7 @@ struct amdgpu_gtt_mgr { struct ttm_resource_manager manager; struct drm_mm mm; spinlock_t lock; - atomic64_t available; + atomic64_t used; }; struct amdgpu_preempt_mgr { From patchwork Tue Jun 22 16:23:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrey Grodzovsky X-Patchwork-Id: 12338019 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 889DDC2B9F4 for ; Tue, 22 Jun 2021 16:24:31 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6178060238 for ; Tue, 22 Jun 2021 16:24:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6178060238 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E5A1D6E5D4; Tue, 22 Jun 2021 16:24:22 +0000 (UTC) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2046.outbound.protection.outlook.com [40.107.237.46]) by gabe.freedesktop.org (Postfix) with ESMTPS id AFD706E5C1; Tue, 22 Jun 2021 16:24:16 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OuZV6j1Klcwl9TT44X68jLaKBhLLwr/d5E33jY9IADG4hgTXz91j85gtH9+RsOOkaA+pBclJD1z0Wgs8qgjbIErhzK+ltkMpLfbw/mjGDkF9mpftGXS/dbTk2fPygnNGTjpHuY+1Efwxn3IWcxGDMkMKItcrzb6aX/xQiDeG4lEsHmggiU9Bcw1If13vrPE4iUoIxu8DBsXsOYspwSkyc6tIYHTXYzrYcYMYDcXfxo6MsZQRuCbBQiG2FcQF7/jUGhqBNdiB8Fys77Q6Z/cAF2elb3Tm7ATqZXgBimqYuBgdrsmqdyA2rSEnuQF3KecFtzBMXzDFsMjxvMIfaIxjJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=C94EjJZFq56JM4fuN39uPzqAcd7PXMxK+uAZIKGoG6A=; b=UiP5z6PkyHZNHMR9BZ6FF2h1OZKE4QV8Z/135CA5ni+aJQMeTqNbCkgPxy94gzz0M+V6ZotRiUTLxhsKWHTBsRsI0eDg6EmxqE/4LyfpOETxTlRB/ICIQL5CKLPkF3WleF8OzhXjA9KdpHGoKMSJPy6PVXDMqrRvVLM0Mm/dAy5iGuPJKPQNw9Wn5KgaZaw1Vjx3BiTRELR2/VnuJablhrW6btoyFkTqwboWxvj5uPbeeVfPCMGyJ5Jfv6vNsR9hSByNRXE7WQ/+bjvzlc0TxzrTBct+GhVeo2tsEP8mnRCoYGyrMgzij/uv7AeZrF4PudNdWd+K6Gjfe+GCctOgJQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=C94EjJZFq56JM4fuN39uPzqAcd7PXMxK+uAZIKGoG6A=; b=1uvG6ewE4MTjmpAm5ZyrU4cgqBhwXVJXvlheoUbTZ80VvV3H09IZbzGwESfr3v1HQOYVYSfIwYcX3mfkLIDz+q3hCt/747N6Nd9qvkMR7+HLqFckU0DP8oMnH7G/MpuelAD7MTl4KRuWlBN7BTmi8hBrK60X5tM47j0EuWEk3yg= Authentication-Results: lists.freedesktop.org; dkim=none (message not signed) header.d=none; lists.freedesktop.org; dmarc=none action=none header.from=amd.com; Received: from SN6PR12MB4623.namprd12.prod.outlook.com (2603:10b6:805:e9::17) by SA0PR12MB4399.namprd12.prod.outlook.com (2603:10b6:806:98::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.18; Tue, 22 Jun 2021 16:24:14 +0000 Received: from SN6PR12MB4623.namprd12.prod.outlook.com ([fe80::9f8:ec71:6535:cd36]) by SN6PR12MB4623.namprd12.prod.outlook.com ([fe80::9f8:ec71:6535:cd36%5]) with mapi id 15.20.4242.023; Tue, 22 Jun 2021 16:24:14 +0000 From: Andrey Grodzovsky To: dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org Subject: [PATCH 5/6] drm/amdgpu: Fix BUG_ON assert Date: Tue, 22 Jun 2021 12:23:38 -0400 Message-Id: <20210622162339.761651-5-andrey.grodzovsky@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210622162339.761651-1-andrey.grodzovsky@amd.com> References: <20210622162339.761651-1-andrey.grodzovsky@amd.com> X-Originating-IP: [2607:fea8:3edf:49b0:5c6b:dde9:a4fe:685] X-ClientProxiedBy: YT1PR01CA0137.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:2f::16) To SN6PR12MB4623.namprd12.prod.outlook.com (2603:10b6:805:e9::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from agrodzovsky-All-Series.hitronhub.home (2607:fea8:3edf:49b0:5c6b:dde9:a4fe:685) by YT1PR01CA0137.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:2f::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.18 via Frontend Transport; Tue, 22 Jun 2021 16:24:14 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: dce55385-2e68-431a-4a11-08d9359a2d0a X-MS-TrafficTypeDiagnostic: SA0PR12MB4399: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:586; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6sJQnLnTVteKJLexe2lGQTD8k9cLNnU+TUh1yCSaauLDJMyV5RaxzSzlGRN0oCIei9bGRscTAeS4tfzGDrSKiQbmQXjs9x33Vv3TwPL+lqzXgtTqmpkJNN8hDrSa2qyzHcfiYgVWvOBXiX5sWEcwWbY+KdjO05Q2KZkVcftvANf8IA5CBAB1En9gQ52dMxQxljImtGqGVrrg/8RQgJdREHQwjm04l5XKPbga6TWHbe5ZkGxrLCe47ol4Lp0VH46OJPBnX3JZSN9y9dwqNKJmH8fjLw1xWMWnu8mUkQTzZyksVz+i1/s89jbqq6+rXsVGeigkUeumHbkIPERF8iM3P8i2RJZsvB2LcS+F374y332+QDvoFE/hVd23Uj7zU1fcCg0+WaOGynCc/D2uFdiG8DmHb39wa0lV/CsbUKbk7B47JE4/E93ZDZ3vkYieVxEyFBEJS0xxxowNelvZs2azpgcwsLJ3aNDn5uveDVVi/gr79YVqp9kio8HQAZBnTlwdDj4aSKJwYHCmwHMYkzxyc+CEd++J15Me4z74sLYBbBNov6wxNMh/nFxYcr0MTJov52GsFYTPl9k3Syu+SCL3/Z/L1ACFpwPIYQSpoYaCnRo= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR12MB4623.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(36756003)(66476007)(66556008)(66946007)(2616005)(44832011)(2906002)(8936002)(8676002)(4744005)(5660300002)(6666004)(86362001)(6486002)(16526019)(186003)(6512007)(6506007)(83380400001)(1076003)(52116002)(38100700002)(4326008)(498600001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 01Y33H60xy+0Z5C9YV146cMb63lQX+mk2JI2/0uqXRXo17VNxqyv2x5CYlOdDp2RblEECTW7bMDZl9cIg1H/4poo5ZZTGff3f/InrkIgWjTxlBuZrwBp7thrDOS8WFKtl4qdc8bGGAmCPyA5ckW7SsErGGQF7pFA54Ae8r0BKjWNW296/MG/DHFvvslaQ7YevuBk6gOcbg5lC9WUaxvS89QaDYfE4LmotgQjOcsxM8VqKymj4MtKOl3R0gFOW8xnK6gA+1suu5Robvvas5uhjCZ4FBXKi7R3SqVbFbFWhE0wGh9PiIck+1Q3OHaZ1FjvIKq8XlYzB6jHg1ZTXKW85ge4GsO+hGzUrpmejKZbGR0AnX1fVQHuyLJumVcGHFP18HcuBgO+LmnraQqmSjnsQkRkUjAoVK7oFl/+AlX4Jg0IAsL34cdcEhtMIgwyUauDTsiKQaNP96o1a/akN13WugyrptGHwVmVTc9LfRgbWvmBdLdDnZxamGLFDithB28u9WCZewYi/o46U/17JirNHyQy9jiAq4CRCNeleo+IxMHXx/JojqdFFrg+S2qRvG7SnD7KAxVPPNBoevVZhHn15NcroxpE7hSIUgloRq8uPXxUeLT6UFl42HfXxbkOuiPm2ex8xNfABqKRXtzIfcMpQNhVtWRPE6MgkynK/RrEi51RLIMIGfSgKVl+89GjtuYrQfBhvtout6DMPWz5wpLaVNlyEvvwDthkJ4MXEEot8HFYflwhTmUEebYfBMSkdQaztCc4oDOGiAJE1kQOyCmKRfRDMNYxl6B0RJ4C54AUc9xaxwtg70g4usA2tq7RjNYgfBWxZVpPe70Vrh88UyQjKX2wGyeQGBJRxF5fS3YDv25YEo2LcJoZ1qkQ3WxFx0NNJSEMVDafz7w3lCjUtYCswbKu1tD2yxROCRH/mJAgNJjrkliYFonyENn7I0jItLC9a6jgo+0PFf/vWVt0SenkqyqMrJLQ07UdUdZc9XhNr56pfezLxOVVyEyv+OOtSP8gjLllLwI3EY86aCK+bv8/eVCpLl7mGHpxdnH6QeNVojQUYUn8FW4+czWoksIEK+WZfikoK7wrtNZmB1tBNPrv3soVvzSfgtGiJTbH1Erw+f6eUeX3PG6HApeHZ3EbALALxpjo9qNX89lI7JI2RE7jn8mwUShDuIbn596eoTRCmCvwTzXYws4/06QPnB+YB/gZnNKVode1xUhoV4P3TvpvP7s8Eo5ul2YWR8f2U271dCpyxJFjSmtmrxIr98mp3AosxrBAFZKxdlMldOjmE1UZc2kH8a9gzWfwySO4JSCZKAwEdIdBynJVGHOkWtauVFGCs8m3cki5/9pWBNxDus5dhBTnnOfXvimdpTsH5G0EABv+eieWXiS0367nLcBAuCa+ X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: dce55385-2e68-431a-4a11-08d9359a2d0a X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB4623.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2021 16:24:14.8739 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: daZA+BWBSq+qnu2OiTEy4z5hM4Rm0Rjc+zSnrrClrbNG2G9y8MDqxfxfQbG7MrcrED9EdrRVc41mVyiCLx2t4w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4399 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ckoenig.leichtzumerken@gmail.com, Lang.Yu@amd.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" With added CPU domain to placement you can have now 3 placemnts at once. Signed-off-by: Andrey Grodzovsky Reviewed-by: Christian König --- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c index b7a2070d90af..81268eded073 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c @@ -180,7 +180,7 @@ void amdgpu_bo_placement_from_domain(struct amdgpu_bo *abo, u32 domain) c++; } - BUG_ON(c >= AMDGPU_BO_MAX_PLACEMENTS); + BUG_ON(c > AMDGPU_BO_MAX_PLACEMENTS); placement->num_placement = c; placement->placement = places; From patchwork Tue Jun 22 16:23:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrey Grodzovsky X-Patchwork-Id: 12338017 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EF105C49EA2 for ; Tue, 22 Jun 2021 16:24:27 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C9EB26113D for ; Tue, 22 Jun 2021 16:24:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C9EB26113D Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E4E156E5CE; Tue, 22 Jun 2021 16:24:21 +0000 (UTC) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2065.outbound.protection.outlook.com [40.107.237.65]) by gabe.freedesktop.org (Postfix) with ESMTPS id CD0766E5CD; Tue, 22 Jun 2021 16:24:17 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QIQ5FNuGLkEOBH5eNQZee8oghqCvC1O2jrFWWAucOZBHTBecX6UIZOB+t5hzKwdDqjcvUyQk0eq8DHTx1QIkynUIiuONnPwpcFcTvSB0sfZJqAeqQ38J0aGyU4EdNRA/G74Mb99MwHUSc77f1AgXEnukHqt3EMwLWGm9GcnRbk6/bLYl9JAadlpr0eQG3VcMe0J3lOBJCACcL138JyQHhLfhKaKmpiGu6UI2D2ZRodWsQaZFch40CIEteWRjDaS0JcoZdZg5PyhMF6jxKV2+zzaFk0S0GUwncPr9sWWLzSzApXxEdivAQerVQGZFJ9T8vPIMzs2vduIpM4KSbL/5KA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kZ1TL2oUsvJFC51IBukA21mX9pZS3FElzBYz+QaKu+8=; b=loOOQifNnoc2wzKnEhTvVvbvJ6mLbMMKgvqj8uWjLWrx030BddN8co1om6vFxW5u0EF2dkT69FMDBlz4qK0ILAexjR/oPA4rgAK37U2voTWdXYZIGSZM0nXNKy5dh6hq9VC/EC37gjG0HLnuihtSNTQ2M+13QelcvJ4S+FLo/rdgKSr6T5Le1mo3/ma40QjF5wnVL3kA/ESJ4kHHxO75AGfUjRSnFP84EbM95nHk3pMGAvKaW1dMJDXTQJg5Ak7Hi+8bZ616z1P2bb6VVDMlXKDfGBX4YbMYOD6EqLhN3epX2T2niD3qb1eN/1kw8Ou7uLlR+bn/zqoPt3AqNVBRDg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kZ1TL2oUsvJFC51IBukA21mX9pZS3FElzBYz+QaKu+8=; b=LAY+NTJp8a2Io6feuzlgnD8iEqGRNIHhTpCQ8A9Cq5C3CJHd1X+INgbC9soGpVeidbKAKTQHInGJMGyx7bqjgAmjhZCeCSz0nsMBAOXluysuVIlY4sCitfWLwM1gfO+VeXGvHewl50k9iX5w6+pheVPtdAspJW9UEYnThZn1ybc= Authentication-Results: lists.freedesktop.org; dkim=none (message not signed) header.d=none; lists.freedesktop.org; dmarc=none action=none header.from=amd.com; Received: from SN6PR12MB4623.namprd12.prod.outlook.com (2603:10b6:805:e9::17) by SA0PR12MB4399.namprd12.prod.outlook.com (2603:10b6:806:98::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.18; Tue, 22 Jun 2021 16:24:16 +0000 Received: from SN6PR12MB4623.namprd12.prod.outlook.com ([fe80::9f8:ec71:6535:cd36]) by SN6PR12MB4623.namprd12.prod.outlook.com ([fe80::9f8:ec71:6535:cd36%5]) with mapi id 15.20.4242.023; Tue, 22 Jun 2021 16:24:16 +0000 From: Andrey Grodzovsky To: dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org Subject: [PATCH 6/6] drm/ttm: Fix multihop assert on eviction. Date: Tue, 22 Jun 2021 12:23:39 -0400 Message-Id: <20210622162339.761651-6-andrey.grodzovsky@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210622162339.761651-1-andrey.grodzovsky@amd.com> References: <20210622162339.761651-1-andrey.grodzovsky@amd.com> X-Originating-IP: [2607:fea8:3edf:49b0:5c6b:dde9:a4fe:685] X-ClientProxiedBy: YT1PR01CA0137.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:2f::16) To SN6PR12MB4623.namprd12.prod.outlook.com (2603:10b6:805:e9::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from agrodzovsky-All-Series.hitronhub.home (2607:fea8:3edf:49b0:5c6b:dde9:a4fe:685) by YT1PR01CA0137.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:2f::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.18 via Frontend Transport; Tue, 22 Jun 2021 16:24:15 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: de273d25-7447-4e00-ff1a-08d9359a2dd9 X-MS-TrafficTypeDiagnostic: SA0PR12MB4399: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PjYA/nW90yO+Bf0jyJplfy3S+nC2FDT0/16LTHt87dIgLeU70pmvQStja9dt5T1XkxJnVXGRMlfCeLQyBtZwREaY9DAfDJhYci6M+ZQOE195XizF30IvoDNEO5CkOOq5XgrNjZPVIa27JAYNPIz15Z+uVL1ZlOXuwdGyi3gRcJI6LGj5oqOgi0b3rngVid6T/hccoJlAFjvHMaHMoTcUBkcmaFQ9Epiq39Ego1qPrd58DLiQVNNNN6fuxqUpC0cu1u80Iejz6pHLxBSUBfjwXNZtN3aFZltGUH6E2HAf4CysPDHYoG7KScOTBnJYK+K2vPIgZz3lMmBhM+xMrJI8WL/GVhFtwLxLedwPUn2iE9BZHCZ8kLs1cunQCgtjCcuCHQDItNBG+lZPPJnV+lD/4YsM74K6O9woEM8BuOBN2IkDkj+A3ttQKXafUKF0S2nGrPWsD2gwdJw2ZAOm73Ud/7hlGsBt70PmCALJS99Fc0EA0Gr4eqHyMarBdUJ6Jdk/eH16ZUnu8NJNWeUnEl4PaSXnRgQobSPPQU3cuFIvMWSfTBc31oSXCcCDhW8ZeO4CH41ZThlnZZuQ9GFauP2F+mA36UVgnnKnAotQWw9jwMc= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR12MB4623.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39860400002)(366004)(346002)(396003)(376002)(136003)(36756003)(66476007)(66556008)(66946007)(2616005)(44832011)(2906002)(8936002)(8676002)(316002)(5660300002)(6666004)(86362001)(6486002)(16526019)(186003)(6512007)(6506007)(83380400001)(1076003)(52116002)(38100700002)(4326008)(478600001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: zOceRIzIc9WCrWI8cjQFS1O+4pe5LczcgGar+g1cyvhcc5nHOHq0yUPeB1d6NV4MqfZ9tB3Ww1ZD9zmFGThLt5S0ON5JQLflER+RSa9NU3rxzbtW0oHaSnMrMs945TGVYcPsKS/J4rthWnI5b3DsJ+lajBAza+y7cv8B4D/olAtkyRM1IeiWDQhCXHmGh1EXSRN+Dw2xfY6W15zj07gV7I6+zhvh0K/q43HYcQ+RSqzsLek/PsU8YluPGU2bvy5pJCFumkIapOfXTeHWUvUOMq/V+3y++Dtna2aRbJ7aFzMrBCGV+1AytfIH8oDrNRp1F2PxgSFt04cC7kinKajP+HvniE/1u5dUeYbQogv2tvqqAAKZZz6owjW4WCbjESqkrrSIaO+V6QGyoog4sFGZAz1sLegsdIWxwA/IDjNAKPoFxtuch1QTs0ct3TauRaxeOlNW2rk9DlptgzsuR5W1YS1vYq/h9ZBAZOD57kutX8F4vKxbyZ8DjB0Pn1lm7yNX6XM3Ee/8je8bPzcsGHymnoJ7nqu/qzitjgJlBCyrHY2WcdWLEReMmuThODAWDM0zScywb/H7lkvcGVaCBh89wITuz2ZWIx2zBLSjZNssnZvDPmR1+549qUdY6zcR1Sepdh6T/0HmV+apyznDM9wcQoIwohCJwxe9xOFOcTbrI6D2pBP4n7UnEHFdkxXVRcr9UsA+8c5Q294i+ZVkp2G93Wnr9jVShSwNwwLL9i7n9aLQAbSF16k/YbKn0WM6uj0VMWrr/Dm8TpzfDO0EY+bFqWtejv/SFoPkF2e2kOblKbxagBFHLNKd353L65g+h5pPtSbQy91G5bTeUOi8mUxNQVczC5ZkJ8+MlarczRRAuBdW0CTZUxcyCqX/OaKpYi/HFQM/BxosD3vGWOdp/h/xlD3NzvXysBLDWEP/njRTFwWEgg0anrIovDyKIVgSyG7lPIqttp+93CIn/Fczpz46hn9oFpQ5/qyOY0F9tWQ9laAfYvWSajn0LyWAx/kfxCSXX0lBHGO+AILYLfLv06OzB0/6VDRbR78aHW4J0+x/VtZoEbJeUqvIxFa9dyD9Sq6m1BAQvVQ5o85tUBzEsRGZHtPPiQJGDNPVo/Xxk2QLs6r89Ermpag0nDkwy5ifPVW9VgopMs2EHWZi1Tu1uKsYl5i8gz6MgIENkHXZ0Ik76kCcq4BbtxQjUEgSaup9IzIuzBu86IUh45c6fEVzb1h+5wIGAYYCLLXWDhfON1s/EcXujr+MQg1H1tVK5m5e5c8Zcs7WZ46QCvGLXNGpDxfVaT63fWQulBG5qbxufD2IpNLMxHIGJo/ueJxq69hjf9Y2frHJx9U3cdLXHqnQdA9c71fgdG8dOCd1isZGr42GCNcuBoYFhSzRLreTGcJg/1pb X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: de273d25-7447-4e00-ff1a-08d9359a2dd9 X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB4623.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2021 16:24:16.2001 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Vb9De1/Yr9NAQ9S83+ztCmzJJyr9Oy9GmbbiNqsk3Y2JvzDDlU6/25bY7nasUbk+mPuFDTJRA8J2DLuYzkdwfg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4399 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ckoenig.leichtzumerken@gmail.com, Lang.Yu@amd.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Problem: Under memory pressure when GTT domain is almost full multihop assert will come up when trying to evict LRU BO from VRAM to SYSTEM. Fix: Don't assert on multihop error in evict code but rather do a retry as we do in ttm_bo_move_buffer Signed-off-by: Andrey Grodzovsky Reviewed-by: Christian König --- drivers/gpu/drm/ttm/ttm_bo.c | 63 +++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 29 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index 45145d02aed2..5a2dc712c632 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -485,6 +485,31 @@ void ttm_bo_unlock_delayed_workqueue(struct ttm_device *bdev, int resched) } EXPORT_SYMBOL(ttm_bo_unlock_delayed_workqueue); +static int ttm_bo_bounce_temp_buffer(struct ttm_buffer_object *bo, + struct ttm_resource **mem, + struct ttm_operation_ctx *ctx, + struct ttm_place *hop) +{ + struct ttm_placement hop_placement; + struct ttm_resource *hop_mem; + int ret; + + hop_placement.num_placement = hop_placement.num_busy_placement = 1; + hop_placement.placement = hop_placement.busy_placement = hop; + + /* find space in the bounce domain */ + ret = ttm_bo_mem_space(bo, &hop_placement, &hop_mem, ctx); + if (ret) + return ret; + /* move to the bounce domain */ + ret = ttm_bo_handle_move_mem(bo, hop_mem, false, ctx, NULL); + if (ret) { + ttm_resource_free(bo, &hop_mem); + return ret; + } + return 0; +} + static int ttm_bo_evict(struct ttm_buffer_object *bo, struct ttm_operation_ctx *ctx) { @@ -524,12 +549,17 @@ static int ttm_bo_evict(struct ttm_buffer_object *bo, goto out; } +bounce: ret = ttm_bo_handle_move_mem(bo, evict_mem, true, ctx, &hop); - if (unlikely(ret)) { - WARN(ret == -EMULTIHOP, "Unexpected multihop in eviction - likely driver bug\n"); - if (ret != -ERESTARTSYS) + if (ret == -EMULTIHOP) { + ret = ttm_bo_bounce_temp_buffer(bo, &evict_mem, ctx, &hop); + if (ret) { pr_err("Buffer eviction failed\n"); - ttm_resource_free(bo, &evict_mem); + ttm_resource_free(bo, &evict_mem); + goto out; + } + /* try and move to final place now. */ + goto bounce; } out: return ret; @@ -844,31 +874,6 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo, } EXPORT_SYMBOL(ttm_bo_mem_space); -static int ttm_bo_bounce_temp_buffer(struct ttm_buffer_object *bo, - struct ttm_resource **mem, - struct ttm_operation_ctx *ctx, - struct ttm_place *hop) -{ - struct ttm_placement hop_placement; - struct ttm_resource *hop_mem; - int ret; - - hop_placement.num_placement = hop_placement.num_busy_placement = 1; - hop_placement.placement = hop_placement.busy_placement = hop; - - /* find space in the bounce domain */ - ret = ttm_bo_mem_space(bo, &hop_placement, &hop_mem, ctx); - if (ret) - return ret; - /* move to the bounce domain */ - ret = ttm_bo_handle_move_mem(bo, hop_mem, false, ctx, NULL); - if (ret) { - ttm_resource_free(bo, &hop_mem); - return ret; - } - return 0; -} - static int ttm_bo_move_buffer(struct ttm_buffer_object *bo, struct ttm_placement *placement, struct ttm_operation_ctx *ctx)