From patchwork Wed Apr 26 01:52:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Joshi, Mukul" X-Patchwork-Id: 13223966 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id B110DC77B7C for ; Wed, 26 Apr 2023 01:53:27 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C74BC10E315; Wed, 26 Apr 2023 01:53:24 +0000 (UTC) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on20621.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eaa::621]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6FFB810E219; Wed, 26 Apr 2023 01:53:22 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TAItYFyAdBhhdEy9B1H9uwsKNk9v2DXY2zs5RcMDaX/1YQN2LlirgOchi96oVdj+MjDNweGeDwecfJfP06N8j/9JrMOQp2ukPswimUJ4t/EV+xSWcluvfYyRUaFpFHoZFmOv2m+5y/IWfA88TTL9Bh521rCVFCPg9UqzstnNtppTdM4RFMXCDFmBAfNKQfrU2+H+UjEO0vubkY6ma6Pg9eiSqC4533mASy2tmLa9JRU9Dt/jl5EKMlWCevPMID0ss7+mz7c7Z1zFm1CAsVR32Na4PO35tVjeMk4VYmpwHcMhYwAeX/c37ID28ne1UxERML118PxrSX0/itL9m+xh3g== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=l4qiBB5aG/Awe7v3DHzcgOybTBkAN/Tq5iS7RYSmHMo=; b=lf36B6CoHTKCw2E5jKXP5WxcKIKO6bS5krinK6JCx1OxEEWPSjTOHDmy0ZhkGG2zFSsUdzlBgZQcyg6EuOvUsRp2XOKUuHI6/bZYYeWc4iXcGe2mHWGT9R+ghd0jgKX+RwXlm0kPhKBqV1/nQCuOqCWrxx13fZZK16xqigDdjGhO07GygU2ivOOO/oh3Tdp6uGIlnGOg4NRStYo9ekKaJC7uUJbeeLtow0TMtm2AOl9Gpe7RU999dm5kWTySaGnZ46PO+dmkEXQ0KW/PG+Z+7+Z3EznwQgocTD4fqfWNcwWIey+nnKotRqLBY/PcvX/nSmi8uGwZXB4SgAdfdqsCrg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); 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=l4qiBB5aG/Awe7v3DHzcgOybTBkAN/Tq5iS7RYSmHMo=; b=HusJTXKtrMqN5B5XpwstpGHM71Tdcl0dWTok177QqY9ng6qwKUfwQczpjjsvcZM/nnu8PPI6iOBcPgelaT1iR5k0aO3fXuj/jxxTJ73qRteSJg8pC9KAd2au0t17UavTlkI7Fk1fd+vo/DrLHG2F1IPPTealgnwzVkeEFegK4Vg= Received: from DM6PR21CA0026.namprd21.prod.outlook.com (2603:10b6:5:174::36) by SA1PR12MB8968.namprd12.prod.outlook.com (2603:10b6:806:388::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Wed, 26 Apr 2023 01:53:18 +0000 Received: from DM6NAM11FT039.eop-nam11.prod.protection.outlook.com (2603:10b6:5:174:cafe::bb) by DM6PR21CA0026.outlook.office365.com (2603:10b6:5:174::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.5 via Frontend Transport; Wed, 26 Apr 2023 01:53:18 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT039.mail.protection.outlook.com (10.13.172.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6340.21 via Frontend Transport; Wed, 26 Apr 2023 01:53:17 +0000 Received: from mukjoshi-dev.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 25 Apr 2023 20:53:17 -0500 From: Mukul Joshi To: , Subject: [PATCH 1/3] drm/ttm: Helper function to get TTM mem limit Date: Tue, 25 Apr 2023 21:52:49 -0400 Message-ID: <20230426015251.551223-1-mukul.joshi@amd.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT039:EE_|SA1PR12MB8968:EE_ X-MS-Office365-Filtering-Correlation-Id: 01ee4e25-e16c-4854-d167-08db45f901a1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oEmziNpGaafYdhKiM97/AdsZBL8OuugvHBw56sfOjlpI86RF4k7y1CUml1U/1fpRDDTmYhh/J9it/OH1pZ50atMeH4ldEgy5h0oaFFNVpqluiP2iNwrJCF0cAsuj3dgUYlsSvjwmR8m7ISMJgZyNS4Z2CMj71C5HxKv7OzUkkK2YceoUUbbDBiC/yaCjmnK7CpI97f7qOT18dJ3tHnXqmp2FBGtY8tjP6kGGS0KHRPKUMOa0eRGsoI2GFjtqPsNXXuBxNKYzKiTZsYemaGT/G2t2CBFE6VjzBcOkCZuDf55q3A0yUDomsUAMlsRaaRA6cDvsTx2d5mVDxXLnUZUHfFPDN2dxRxTyK66vHotqx9HydCua4gfIsvr4jz3nRW5NWdBToYEKEZDnvVSHYR1CBillG3+NeS28hFIyLtsMB7r7N1lChkNlwzvXTocSzikdBnq8K1s535fIvF/0VGsn4mIS90NFx831sHCFKbYOx83NUe+ha+ShWOySNVFXj2G5tYwBhXdfYaxFcPsSUCVyA8KRCokbl6u3C30YREPNXcoAnManZkx6LHrRBJjQQVrBGsEecfDD2tukelkiME+UOgvFEEJ7v7epExqN8mKIRNaIEOpH/qjy3mNGPX9ufQV95niceaijwfJk8GrcIcVAKCn6QQrUvFuZBRukIHLSqjCxOtZcvKk2N96JUYoBLWxNxl/bWRl12JWDydJsEDYXrjj4hLOsIoPVTZDsAhypH5k= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230028)(4636009)(39860400002)(396003)(136003)(376002)(346002)(451199021)(46966006)(36840700001)(40470700004)(1076003)(26005)(40480700001)(426003)(336012)(2616005)(36756003)(83380400001)(36860700001)(47076005)(82740400003)(186003)(16526019)(40460700003)(356005)(81166007)(70206006)(86362001)(70586007)(478600001)(8676002)(8936002)(54906003)(450100002)(44832011)(110136005)(5660300002)(7696005)(2906002)(41300700001)(82310400005)(4326008)(6666004)(316002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Apr 2023 01:53:17.8831 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 01ee4e25-e16c-4854-d167-08db45f901a1 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT039.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB8968 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: Mukul Joshi , Felix.Kuehling@amd.com, christian.koenig@amd.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Add a helper function to get TTM memory limit. This is needed by KFD to set its own internal memory limits. Signed-off-by: Mukul Joshi Reviewed-by: Christian König for the series. --- drivers/gpu/drm/ttm/ttm_tt.c | 6 ++++++ include/drm/ttm/ttm_tt.h | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c index d505603930a7..1f765dd7792c 100644 --- a/drivers/gpu/drm/ttm/ttm_tt.c +++ b/drivers/gpu/drm/ttm/ttm_tt.c @@ -449,3 +449,9 @@ ttm_kmap_iter_tt_init(struct ttm_kmap_iter_tt *iter_tt, return &iter_tt->base; } EXPORT_SYMBOL(ttm_kmap_iter_tt_init); + +unsigned long ttm_tt_pages_limit(void) +{ + return ttm_pages_limit; +} +EXPORT_SYMBOL(ttm_tt_pages_limit); diff --git a/include/drm/ttm/ttm_tt.h b/include/drm/ttm/ttm_tt.h index b7d3f3843f1e..d54b2dc05d71 100644 --- a/include/drm/ttm/ttm_tt.h +++ b/include/drm/ttm/ttm_tt.h @@ -222,7 +222,7 @@ void ttm_tt_mgr_init(unsigned long num_pages, unsigned long num_dma32_pages); struct ttm_kmap_iter *ttm_kmap_iter_tt_init(struct ttm_kmap_iter_tt *iter_tt, struct ttm_tt *tt); - +unsigned long ttm_tt_pages_limit(void); #if IS_ENABLED(CONFIG_AGP) #include From patchwork Wed Apr 26 01:52:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Joshi, Mukul" X-Patchwork-Id: 13223967 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 343B5C77B61 for ; Wed, 26 Apr 2023 01:53:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 04D0010E858; Wed, 26 Apr 2023 01:53:32 +0000 (UTC) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5D25710E858; Wed, 26 Apr 2023 01:53:29 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TDRl5e+G625h5xXAhNDrBIjjJ0QIA5D0nC3gVpa3+W+0rRVxUUshCR3knD/SmLM6+3ImBCKm+oYgRD8GLPh3pAbyzCPUmzWFMOpd10o1UT385njn+q3ANa8v2wW3h6NXqhROSCWfEj90G05CJwTRNW8wylhxiJihKrb5Q/dVfyj8VUjaVVptTfI8ryG4kLgehOLBdgUhfJrXsGDt5538pKGPGLJ75F3PaChMj1MkQjikFTHZT/agmaw3mkshLLtNOE+Dfqfgb7+zNrZIsBxjgIRT/oMJTcEzuziAWGwmLrYoj5hUtnYUpRj6YCruHdt0k7Ud2XcvNCzri1r7tQ1pOg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ta7ExdC0ROnAVZPX1BfzU/wBg3W16+OHIEzL12nHjnk=; b=FlF6qs9KnxaKA2+kXtUW5Z184ns0t1/7BCs+OtldZ8rMEUXFZtPdWCOIgvNiDQW0jJdv5Ic9X89yfKLnBTqEqykP56daN4HJkfDo53s7/u0fqJZTlG1Tk5AwcnBNSC380OJLBSMdJtmrxEf6XavUYq2APp8j5dUD/u+kSt+0p2wpvwU2vYL6oqMSPBhvar3z6vkgaF3YswE9qcDg4ArFJ4lPnPHi72Y7MfWp/WAQFGXkpZO10672OXPFHMW0ybBFqd4zMP9Zrf37N5DgJL+3f0a+XXvVl/CeMQheuwBcJIEqP0gRbGpoaLwOU71aFfMgGh25zWq32vpxlwkN0G62cQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); 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=ta7ExdC0ROnAVZPX1BfzU/wBg3W16+OHIEzL12nHjnk=; b=uHJcnQBt0fRlGfRS0ivn6IFiTA4tQF4M0DGV6SORz2vmdI/6K/Bg07QG0udysTVnxo8hq+LTQ0p6vM9iE6Xhvr6NLWsmavmImD3TqlJ1sCbGyt3jAWtd26ti8prxkCHevLs8EbLKIoqX/NAezoYoVD3szq+JgqVL0RsUbNKJBF0= Received: from DM6PR07CA0107.namprd07.prod.outlook.com (2603:10b6:5:330::21) by SJ0PR12MB6782.namprd12.prod.outlook.com (2603:10b6:a03:44d::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Wed, 26 Apr 2023 01:53:24 +0000 Received: from DM6NAM11FT028.eop-nam11.prod.protection.outlook.com (2603:10b6:5:330:cafe::f3) by DM6PR07CA0107.outlook.office365.com (2603:10b6:5:330::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.35 via Frontend Transport; Wed, 26 Apr 2023 01:53:24 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT028.mail.protection.outlook.com (10.13.173.140) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6340.21 via Frontend Transport; Wed, 26 Apr 2023 01:53:24 +0000 Received: from mukjoshi-dev.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 25 Apr 2023 20:53:23 -0500 From: Mukul Joshi To: , Subject: [PATCH 2/3] drm/amdgpu: Set GTT size equal to TTM mem limit Date: Tue, 25 Apr 2023 21:52:50 -0400 Message-ID: <20230426015251.551223-2-mukul.joshi@amd.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230426015251.551223-1-mukul.joshi@amd.com> References: <20230426015251.551223-1-mukul.joshi@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT028:EE_|SJ0PR12MB6782:EE_ X-MS-Office365-Filtering-Correlation-Id: e59bc703-2f50-43d6-801b-08db45f90564 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IxoKgANFpQXGIjT1NTqVdilpSTqk9taay6L4qfB76TWv2nKDA5MF0QyBPcs+imZvWe/k7AwqBt1jBxrflK/90tP0HquXAC1pqrBw/82gEugHBiy4ev1b20rTIKx+ltmf8LVtSDsJGmu0TnAdvNPbvVDX8mZWhP5UToSLvnAwbZLS8TLCCjhftfJ6WmlRqAsW99IHmLXT1qAhscUF0QbADmkuwtJetmrXvihzZzgLwqY8iMbzCWZIwVX5chhJQNuPKZ82BjMEsn9txgfy7/uXSRhLFQnJunxg80XhgldaFdxHITdsJ1B46AXjuktDlu2HcoN2fxQYEZR4/smGP2k7slPEmIPMmhJ6tCuoiID1c7ttJ0ezOFXvbapHy32NPN8VWfKADqVGJXaIyrrOud8NDOUcHWrtQhsBUEkHiAFyU+gx1AvudOhoN30dRNNZPqYPkb3/5R3QHNFVLyeqlzrnBEGLilZHsElkjXltvNgZXu1QcZN/J5l3WuDG9vDmJ77dg1SgaajmPXRlgcm7S3T81NgATuszQZoIAbB0XmasrASp/wcgQR1Fa1qkkSpd4j4ki8SRGI2wu9wL7bjFz81IxBqSAvtTO2YTbnXbSxDFiibQ+V4XeJblsPxWbCkJLvDVBSvo9NfVp6iysEtE/zONB/23ONnfFBNnP6nw/j5SYhUxicHfN4DlPdxQdwTILqUm1cilZugji26tWfhZn1yC0PPk//G4JlRQoz4/plWq96A= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230028)(4636009)(39860400002)(396003)(136003)(376002)(346002)(451199021)(46966006)(36840700001)(40470700004)(1076003)(26005)(40480700001)(426003)(336012)(2616005)(36756003)(83380400001)(36860700001)(47076005)(82740400003)(186003)(16526019)(40460700003)(356005)(81166007)(70206006)(86362001)(70586007)(478600001)(8676002)(8936002)(54906003)(450100002)(44832011)(110136005)(5660300002)(7696005)(2906002)(41300700001)(82310400005)(4326008)(6666004)(316002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Apr 2023 01:53:24.1921 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e59bc703-2f50-43d6-801b-08db45f90564 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT028.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB6782 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: Mukul Joshi , Felix.Kuehling@amd.com, christian.koenig@amd.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Use the helper function in TTM to get TTM mem limit and set GTT size to be equal to TTL mem limit. Signed-off-by: Mukul Joshi --- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index ce34b73d05bc..ac220c779fc8 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c @@ -1807,26 +1807,13 @@ int amdgpu_ttm_init(struct amdgpu_device *adev) DRM_INFO("amdgpu: %uM of VRAM memory ready\n", (unsigned) (adev->gmc.real_vram_size / (1024 * 1024))); - /* Compute GTT size, either based on 1/2 the size of RAM size - * or whatever the user passed on module init */ - if (amdgpu_gtt_size == -1) { - struct sysinfo si; - - si_meminfo(&si); - /* Certain GL unit tests for large textures can cause problems - * with the OOM killer since there is no way to link this memory - * to a process. This was originally mitigated (but not necessarily - * eliminated) by limiting the GTT size. The problem is this limit - * is often too low for many modern games so just make the limit 1/2 - * of system memory which aligns with TTM. The OOM accounting needs - * to be addressed, but we shouldn't prevent common 3D applications - * from being usable just to potentially mitigate that corner case. - */ - gtt_size = max((AMDGPU_DEFAULT_GTT_SIZE_MB << 20), - (u64)si.totalram * si.mem_unit / 2); - } else { + /* Compute GTT size, either based on TTM limit + * or whatever the user passed on module init. + */ + if (amdgpu_gtt_size == -1) + gtt_size = ttm_tt_pages_limit() << PAGE_SHIFT; + else gtt_size = (uint64_t)amdgpu_gtt_size << 20; - } /* Initialize GTT memory pool */ r = amdgpu_gtt_mgr_init(adev, gtt_size); From patchwork Wed Apr 26 01:52:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Joshi, Mukul" X-Patchwork-Id: 13223968 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 8D2EBC77B7C for ; Wed, 26 Apr 2023 01:53:39 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B7D4210E85F; Wed, 26 Apr 2023 01:53:38 +0000 (UTC) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2046.outbound.protection.outlook.com [40.107.93.46]) by gabe.freedesktop.org (Postfix) with ESMTPS id D278210E85A; Wed, 26 Apr 2023 01:53:34 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LrIY22a1R1nas76pMQsr3GP0QJVYGyRpNo1MrNdtmq5MLZUGZke0eeUl//JHuPmR0vMlPqMMpqeH15MJOHsacgqx9f6pDVjrMa/Uzn03PH2l25HR4UmX6w7BejTNUE/GkZgzv5snQT3JdSMeRgFHnVUnLeiLxILOih21kAOg9QmSGx69cfhoHxeih85rCW6ko7dSP1zpvUM0ZrEUOLQ7wbEwOIJCXztZl3HFYXxwVEwKJJHpubO/4jsecYa5D+/Ncc4zhSpgIxBoyuV9sgvbu2BFVqPHsh4al+I/r1IttruZjlxkOpVuwZ8btdDuf7/3k7H+lxTOZLgy5Bx1UbsUWg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=s8KF3RBhh7gAyaMhhKJtTEG8FmQpurj1kHgGTgvrvew=; b=UfRepsSavOunOT43WZfOEZ59GiT/Bx/cbwojts50wTLM/vB9UjDxdpJn41qGySPEEcYo8hOtE7S8Sp8+1MZI3e3al0yC3vjoR8UACdjbs/kqu2RqiVtxhbkJE5j5T/zpU9X+gypZTevKl1ckuIsMtbEaHYtnNPZJZhES7mlgu6F+CF9WLydjAAi3vFWIJPaWybezZoXAhKfNBSQtM3uQRenQURLLAnD4FK5Pcrkgw8/mpL2HJt1ZjkBZcWfK/C7i1bZukbPMilMDtPleETBrIz5Y/vt046xL9CDYb2oLbFlSBMgzY0ZSEGPn4pNUv90HK/Bnm/0eMcbwad8FRZ0FkQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); 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=s8KF3RBhh7gAyaMhhKJtTEG8FmQpurj1kHgGTgvrvew=; b=F4153ZwEEmIXorKaj2D3hyg1mMbHFlnuiUSfrsf24bE9FKyEI9JwFXOMalEGxdYXK2naIRlsCWg4qyPWIstiaRdwgHZ4hELLjPMGoFomv71UtCCV85Nph/bLWg75is12b7TBcvojlluIaXH+2kHklUE8PM8jnwxK6n+d/AE5vW8= Received: from DM6PR03CA0069.namprd03.prod.outlook.com (2603:10b6:5:100::46) by SA1PR12MB8920.namprd12.prod.outlook.com (2603:10b6:806:38e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Wed, 26 Apr 2023 01:53:32 +0000 Received: from DM6NAM11FT050.eop-nam11.prod.protection.outlook.com (2603:10b6:5:100:cafe::54) by DM6PR03CA0069.outlook.office365.com (2603:10b6:5:100::46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.34 via Frontend Transport; Wed, 26 Apr 2023 01:53:32 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT050.mail.protection.outlook.com (10.13.173.111) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6340.21 via Frontend Transport; Wed, 26 Apr 2023 01:53:32 +0000 Received: from mukjoshi-dev.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 25 Apr 2023 20:53:31 -0500 From: Mukul Joshi To: , Subject: [PATCH 3/3] drm/amdkfd: Update KFD TTM mem limit Date: Tue, 25 Apr 2023 21:52:51 -0400 Message-ID: <20230426015251.551223-3-mukul.joshi@amd.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230426015251.551223-1-mukul.joshi@amd.com> References: <20230426015251.551223-1-mukul.joshi@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT050:EE_|SA1PR12MB8920:EE_ X-MS-Office365-Filtering-Correlation-Id: 9995e102-0bd5-43ce-3bd0-08db45f90a23 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 57Q1vGeokc7jjWn0c8jJPpXFVbjrvxBbtHuxa5L1H9qRXC0OVqap1IvQcz/4p9tIHFO0GkVFREtFlCCXaU9+43eSHP4onhhddEW6GpLom9QMkqXMazO+6iuuP5B4ghtTnqeG4NCvoDFkwjMtkTnqZn8u73BYoRlKGsROuK1MeMgGWdwrUFeIJaIk0j8/wHfEXYXeoTkNMNXzDRqjwhQY1sDKZXEmIhYENAdEd5oV+SZ7d2S7FPWjI0FxYgxTzvtuQA8BQFXnsBARRl17odn/pfY+1JlJwfgKlGtSeeivasmOncl6LhlntxafafD85MXnXqs/G/xM0mq6Pp/7+rxcsLregneFduVemOc48FbKTI19YAy4pdmHvu7+G9DkF7cwTMQ3o5t3p+f2FyfKrRojWZFtBXclMp7TUMXuKTebLs9UH61c2Iqeab0kDgrw37h0A894ySGBuEIp7t7r6gX+Zo+6Unzn1gr+KBDiILJ9RCRKKEoXaHvZsZWtGlKa7YvuqqdOcx+8aTJnAB8r+9GUhR9DXnoXFORBAwxwrXZo7SUF1/r7PP3DLtXnFd5A+363a92kqs+e8uLrzBJ7vt0PelXzRctzlJVmRZBSLfTC9HHnRUCWrI42OVHUdXQSUdExBEzU1M1pjRV3at8Nx1Yes1KL0u1GC3J9vIWRVdonfYsZjyiKGcXhi5fZpwgs5u+JU7gtorkbOYCXlAOfYjh2+kfRxc7xqHIuydRCWY/5vKQ= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230028)(4636009)(376002)(346002)(136003)(396003)(39860400002)(451199021)(36840700001)(46966006)(40470700004)(478600001)(16526019)(40460700003)(110136005)(54906003)(86362001)(36756003)(186003)(26005)(82310400005)(1076003)(40480700001)(4326008)(316002)(6666004)(82740400003)(44832011)(83380400001)(70206006)(70586007)(36860700001)(450100002)(2906002)(41300700001)(336012)(8676002)(356005)(426003)(81166007)(7696005)(5660300002)(8936002)(47076005)(2616005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Apr 2023 01:53:32.1530 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9995e102-0bd5-43ce-3bd0-08db45f90a23 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT050.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB8920 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: Mukul Joshi , Felix.Kuehling@amd.com, christian.koenig@amd.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Use the helper function in TTM to get TTM memory limit and set KFD's internal mem limit. This ensures that KFD's TTM mem limit and actual TTM mem limit are exactly same. Signed-off-by: Mukul Joshi Reviewed-by: Felix Kuehling --- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 3 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c index fed8bb9a721f..a46285841d17 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c @@ -53,7 +53,6 @@ int amdgpu_amdkfd_init(void) amdgpu_amdkfd_total_mem_size *= si.mem_unit; ret = kgd2kfd_init(); - amdgpu_amdkfd_gpuvm_init_mem_limits(); kfd_initialized = !ret; return ret; @@ -143,6 +142,8 @@ void amdgpu_amdkfd_device_init(struct amdgpu_device *adev) int i; int last_valid_bit; + amdgpu_amdkfd_gpuvm_init_mem_limits(); + if (adev->kfd.dev) { struct kgd2kfd_shared_resources gpu_resources = { .compute_vmid_bitmap = diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c index 862e94fbf53c..1002c7834386 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c @@ -35,6 +35,7 @@ #include #include "amdgpu_xgmi.h" #include "kfd_smi_events.h" +#include /* Userptr restore delay, just long enough to allow consecutive VM * changes to accumulate @@ -109,13 +110,16 @@ void amdgpu_amdkfd_gpuvm_init_mem_limits(void) struct sysinfo si; uint64_t mem; + if (kfd_mem_limit.max_system_mem_limit) + return; + si_meminfo(&si); mem = si.freeram - si.freehigh; mem *= si.mem_unit; spin_lock_init(&kfd_mem_limit.mem_limit_lock); kfd_mem_limit.max_system_mem_limit = mem - (mem >> 4); - kfd_mem_limit.max_ttm_mem_limit = (mem >> 1) - (mem >> 3); + kfd_mem_limit.max_ttm_mem_limit = ttm_tt_pages_limit() << PAGE_SHIFT; pr_debug("Kernel memory limit %lluM, TTM limit %lluM\n", (kfd_mem_limit.max_system_mem_limit >> 20), (kfd_mem_limit.max_ttm_mem_limit >> 20));