From patchwork Sat May 1 01:57:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Kuehling X-Patchwork-Id: 12234561 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=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 001C8C43460 for ; Sat, 1 May 2021 01:58:24 +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 96B88613F7 for ; Sat, 1 May 2021 01:58:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 96B88613F7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none 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 C5B9F6F620; Sat, 1 May 2021 01:58:21 +0000 (UTC) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2081.outbound.protection.outlook.com [40.107.92.81]) by gabe.freedesktop.org (Postfix) with ESMTPS id DACD16F61F; Sat, 1 May 2021 01:58:19 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iVsMLpbxVZd+TIQ6YWvoIIfJJtThZrUL4yDbWaN4j8mlaegzjA10KxfwslcGgPuk8/3siUPnTAVPjoUWU6wES4JXyubNT8pZKo7QHIxhM5eiaQNm+0oXxMtfXV70Qm+RhdvJockNWkvruBV3VuW3YlAfY7SLI/HR/X7MZ86anVMsb5y1wb4sHgfZEAX0QDx3uk0OA6oSr/CIs9YoUXDm7R81eXKa56+CqpjclV5zHkoSIlZoQKZTMOeMpuVUYnam3PeNkXMgaUCbXOPnzYbhunMxuO81OtyUJsJj8y5emcI6lSZh1Fdap03sXSSU0uVFuRcYB1MXnvpKfCcCSHMr9Q== 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=yuQnSSmDusIxc2d9HNoy/hMJy0kIIPNL/VqX21Q5dRk=; b=mMb1uDGEZtnuG47RiX0OGAh97rkyGWi2XmLRtcnmOP0U5mjhOLZvcIy3q6DbOiAyC84s+lUVKn76IN+IJPlf6cW0cu0O6n70hE8ZTEZfbDS60QJJ0Yhha1E5w0aCjUv+brJOWgtvUVO1BwFxzloVHUgdCbsIcNlZjtIJtjYo1api+aFS1zuyTShNocToIFoH1o9WH9K6ghfDDk+XSr7BmaypkutonfxEvRLAwoeAoSU5LAH4w1eNb64f/sUJFt0oXKbNbTBEXBzZDkYIJJ4OCya8hfFsXjyx+YhzE+Qw+6mNE8kWU9hv9TnZVn37eADwqW22wTGfvShD2LJGwQjD+Q== 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=yuQnSSmDusIxc2d9HNoy/hMJy0kIIPNL/VqX21Q5dRk=; b=xc/9YeMjMXOSghCQhpOurqSeZmwE/gspT/pf+Mn56bSwWSQCbr1IZ+EJ3fmUNc+YD4qednza0i3ys/Tbnl0zYNFuBg1lCfUPGkcs3U76ZxwuGDqCA3ve+lMVlRM02qH2ge6iCfw9I5TgoFT7pzKg6x4pI3sdj8+xk28eZfPiia8= 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 BL0PR12MB4948.namprd12.prod.outlook.com (52.135.46.212) by MN2PR12MB4142.namprd12.prod.outlook.com (52.135.51.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.25; Sat, 1 May 2021 01:58:18 +0000 Received: from BL0PR12MB4948.namprd12.prod.outlook.com ([fe80::70f5:99ed:65a1:c033]) by BL0PR12MB4948.namprd12.prod.outlook.com ([fe80::70f5:99ed:65a1:c033%5]) with mapi id 15.20.4065.027; Sat, 1 May 2021 01:58:18 +0000 From: Felix Kuehling To: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [RFC PATCH 01/17] x86/configs: CRIU update release defconfig Date: Fri, 30 Apr 2021 21:57:36 -0400 Message-Id: <20210501015752.888-2-Felix.Kuehling@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210501015752.888-1-Felix.Kuehling@amd.com> References: <20210501015752.888-1-Felix.Kuehling@amd.com> X-Originating-IP: [165.204.54.211] X-ClientProxiedBy: YT1PR01CA0037.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:2e::6) To BL0PR12MB4948.namprd12.prod.outlook.com (2603:10b6:208:1cc::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (165.204.54.211) by YT1PR01CA0037.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:2e::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.25 via Frontend Transport; Sat, 1 May 2021 01:58:17 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 309778f5-02a6-4a60-c33f-08d90c449734 X-MS-TrafficTypeDiagnostic: MN2PR12MB4142: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:935; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Twyf4XMI2mqWV6medNcwxIIh+tNPNKpigyCSzmMyR+DULa98CglykiOUNJn/XU0VAQkrjMAXEERjiR5eQzFxQkFNNq+QlDIRGn4Yu/4A9CyNuHuXyQEtLR/wAyFCcf9jm2LImgRp1fnr7+4JcmQiC04qsW2ITXMLqdzzkycbu2L88m67IU+A/F2bXJWomEiVmM26o8Bei+Sxgl8amSNP3nxWY5BjpDNvbzOYZ2jtq+k1RHjrvB62SCSp+BJ2/tQoImh9vWUZcyxj9o2eaC0f2m409NGTmo11ANahHuLWrSUDRrT0UBsRGwy1+zys0I11nf1A/8z4Rl7L7DwFZXZfc5z3LQJeTKU/0FSi/AlX7YeFxypv5K6KoR5Pd+iBQqlZNd/WTHkTA1FQoK7513vxD24/cmgKyoQRromxV98yrhROCPTZ5FePqIPT/p/4lZ7iLtrYXmHhHCmVDhETonHRIOBoEPcDOnNbKNuxb4sndRBwpAcrd6qvRpQrohhbvbHVC+b7sBhxQIhVl7B9kCYfX8KIMZZw95tZgnA/BKhRT9z/j87ulrXIyDBy1kFaWZ41Qio1wQqMriruIM1QSSLbcG/IfCqdjr7ApEpo2mK9O5MOPnLKLWFGytKnibobdggfWZeo0bx4/WULT9bmaWcqM6L8awSSV/PCVx3VvAGdzUUL80Yljl7ivOlUE9mWIpe9 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BL0PR12MB4948.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(346002)(366004)(396003)(39860400002)(136003)(15650500001)(66556008)(6506007)(2616005)(66946007)(66476007)(52116002)(956004)(38100700002)(6512007)(450100002)(4326008)(8676002)(8936002)(478600001)(2906002)(6486002)(86362001)(26005)(186003)(16526019)(83380400001)(5660300002)(1076003)(36756003)(6666004)(316002)(38350700002)(69590400013); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 23SsFof+4FtxGoGAXZxBWaUArDc+Fm6KPHr+SoFyeSti7RFvu7UJ7OSn/65cPu0tb3/s69+JvwCmC5Zkdw6o01TK+bP2zJh1qoBu23nseREOsVJmOK5YngbN6OcVeVVYb4Jhd+jnTnfIZPVE3RcotEOvpj7riweuaKkq/L61ADXpKjcR83AA89GisYxXlpzuNqGL4ZPY/E3+sr2OAQaKYAiOQmIQSv/t+ETh4RrPl3i80ee0Ur347ZUR/LJKWRj4RQY01NM4JsQ1g9J3xfo9s1eVa5SfuJ5fKmzCpmNGFwmVE4AvoFCFhnlp8llVqMWHAZYO+GAEsg08EI11rLPVIgkK3H8ylJCYUBsu2iL1Q1bgrD9Ln9DlR/HPxVIhVoaRD7/kJ9bkwy7oO5uuOB+ZpylRy6nN240erek/FPZFBr0CxcmQ8rPKHBweN9+q7tiOM9FZv/RKbdAxpNLlAafakXJgge3W32C8uPLW6jrI6BumtBiYgodXPqCxylhYoIWNBgrAN/8Ho1LowtzbJG9MjSSar8wAggBBV0SYYpOGNBNjhfELd+S1Q03RUx4Gy4PRbuiHYqiiZsO53IVswQvDldwK/YSxnr8XLCaLADeQuPbp+jIfQCVCc6sxscWBzlyhpJQkC1QfjW9FcgOd+R3sbNSRBEbJCGk5CbdpMUKdLpQadVk7m9oFI7Rt0PZY/okcyaq8ro3Y1qYYBExwzJJxf1KsHWns60mhqindmQwJ+C451nrUFWvb7vFAJkhRxui/StzzH5kXZLj8lUKhvG73y4+oOouJLJa8KtZZk3Noi1JqvEjcBtQQK5/2fp5Z7pKyoyvKOGeFzz1eNzz1PmTuIefDsS+p+Q+HiIiTf5b6AZ0yWJ5nGvJ9+WzlO2y0HpGW4duGiYKUXubVYtMXKClDtAqQ/NgiAccbHg9bOadnvwUZEFyH8nZpJ3E/whDDl5cyvr9oZ5hUhfnEDMVc+KoUfXNlS8psbBXXmHhLPolsk5YzYFqGhj8Ui/xWFiGVm41Dco7Ujc02EwWPxn7oe1vvuDNQ7JpHKEx/EeorE+1bK6sdUow6TFVzm2J3bc9ETbsMKgcLbdvwQcvAXUyoZ4wQAD8LZYSZse5qgHDvCemkMCoKXLPrIl//jQEiPjA+iATghxCh77hhCQazNemAQaVj53xvJvRVhoWzB7w20RsNC6eibM5lVflyQ2rItYB3m084ayuPqUdTvrtxFXfxnQeRDeF5LM37TQY7O9YpaH2hSS1rpM6gUQg5muKMUmak5tGf51FzA76FxAJxOVYlu/B2nRHovevGV1KTS2u7x2HzQ60e/a6bOVSpGOn2WYWRKrzs X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 309778f5-02a6-4a60-c33f-08d90c449734 X-MS-Exchange-CrossTenant-AuthSource: BL0PR12MB4948.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 May 2021 01:58:18.6062 (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: X6+GPUZOWfUdyVYmDE+y1jSxfpy2ynyB+Ce0L6Fu8W30lFVB7olZ9sPrdDBTipe46ZRlMPE8DY2Irz//jlZfUw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4142 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: Rajneesh Bhardwaj Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Rajneesh Bhardwaj Update rock-rel_defconfig for monolithic kernel release that enables CRIU support with kfd. Signed-off-by: Rajneesh Bhardwaj (cherry picked from commit 4a6d309a82648a23a4fc0add83013ac6db6187d5) Change-Id: Ie6fe1e44285f4fccc17092baee664e8d784851fa --- arch/x86/configs/rock-rel_defconfig | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/arch/x86/configs/rock-rel_defconfig b/arch/x86/configs/rock-rel_defconfig index 16fe62276006..9c46bb890879 100644 --- a/arch/x86/configs/rock-rel_defconfig +++ b/arch/x86/configs/rock-rel_defconfig @@ -1045,6 +1045,11 @@ CONFIG_PACKET_DIAG=m CONFIG_UNIX=y CONFIG_UNIX_SCM=y CONFIG_UNIX_DIAG=m +CONFIG_SMC_DIAG=y +CONFIG_XDP_SOCKETS_DIAG=y +CONFIG_INET_MPTCP_DIAG=y +CONFIG_TIPC_DIAG=y +CONFIG_VSOCKETS_DIAG=y # CONFIG_TLS is not set CONFIG_XFRM=y CONFIG_XFRM_ALGO=m @@ -1089,7 +1094,7 @@ CONFIG_NET_FOU=m CONFIG_NET_FOU_IP_TUNNELS=y CONFIG_INET_AH=m CONFIG_INET_ESP=m -# CONFIG_INET_ESP_OFFLOAD is not set +CONFIG_INET_ESP_OFFLOAD=m # CONFIG_INET_ESPINTCP is not set CONFIG_INET_IPCOMP=m CONFIG_INET_XFRM_TUNNEL=m @@ -1097,8 +1102,8 @@ CONFIG_INET_TUNNEL=m CONFIG_INET_DIAG=m CONFIG_INET_TCP_DIAG=m CONFIG_INET_UDP_DIAG=m -# CONFIG_INET_RAW_DIAG is not set -# CONFIG_INET_DIAG_DESTROY is not set +CONFIG_INET_RAW_DIAG=m +CONFIG_INET_DIAG_DESTROY=m CONFIG_TCP_CONG_ADVANCED=y CONFIG_TCP_CONG_BIC=m CONFIG_TCP_CONG_CUBIC=y @@ -1126,7 +1131,7 @@ CONFIG_IPV6_ROUTE_INFO=y # CONFIG_IPV6_OPTIMISTIC_DAD is not set CONFIG_INET6_AH=m CONFIG_INET6_ESP=m -# CONFIG_INET6_ESP_OFFLOAD is not set +CONFIG_INET6_ESP_OFFLOAD=m # CONFIG_INET6_ESPINTCP is not set CONFIG_INET6_IPCOMP=m CONFIG_IPV6_MIP6=m From patchwork Sat May 1 01:57:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Kuehling X-Patchwork-Id: 12234563 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=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, UPPERCASE_50_75,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 6C7D3C433B4 for ; Sat, 1 May 2021 01:58:28 +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 31269613F7 for ; Sat, 1 May 2021 01:58:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 31269613F7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none 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 2EA426F621; Sat, 1 May 2021 01:58:22 +0000 (UTC) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2043.outbound.protection.outlook.com [40.107.92.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id 06C2E6F621; Sat, 1 May 2021 01:58:20 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A+DiHdNcQgzvxCMi0c9d8vU29UpNZY4cFqUWP6W0iTPJPU/uXoAcaVU1RNoHUDl65cIznmAcQ/oB/N9uLfeCnOylVd3K+1U76kT4KmEIeAHYTmA3CqIu3+dO0Ope2+kzly5226VbxqfCyI/hOZXkTayp+i6BaAFRSy0MfjXLe1ooyttj6i5gzIn7Awkx3yKpOB0Ju8eEUMRmT1+BGnInf/lNSAq+UCknS7wx6OkGQVfRMpDxa09St63OFXjb02VGuDmAih9W8gKjcA/MnNfrHEVIhrYMgJaRdURZEJbjpW/TI2Yn6uJlYzQW4mpLAHo/FTZBeoux83w0UZFN6Nhv2w== 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=In+qYMWsP5Vd8vY02PjeYxA4bphaUOxBsuGP0Kfs2b4=; b=KhrY8258BTXM+2lxWl7+nKsToxCaVfAqaaw9iB8b8qfHpP0vjwOng6TK7V7TRiJKsFf+jnyCUiA26o1VBLuk2YT6aftlAY+BdeOZIEWC++udVpmiYp4lfPzhBeexbbDooRhz+j9EdBOvMUu7OO9k2JjZi6+jcQwNIHNirn5wBQS8kDGNiem2jHdgj81UNEP8xnkN6rJOKgd7m02WRBE7xQaCCZPsCPOosDyTTAG62iTtZJ8UVmhH18xFjgdpGYOMZ4vzoM4qQlUwDLdVMalCvMWkCYWWQD4xHTniD0hXaHwoq5j16OwjM1RWi6N7NmFRQ4QMBEsrQVQayWo1JMsefw== 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=In+qYMWsP5Vd8vY02PjeYxA4bphaUOxBsuGP0Kfs2b4=; b=oKJQTdjAJtGvnfkyJIAMjmHVUtI+zVeRIhH2quU6SarGzRRKSXAyKb8nW8vkCPHo1Jcd4+wgIChrmoNKoH4HPHkr1pexSp4pH08McFA8zkiqF9s8I2HMo6O0qR4UO96G3qNsq/aLfbYzzFgF/Cd2LRxRTmFSODIuQ1L/8CWqOlQ= 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 BL0PR12MB4948.namprd12.prod.outlook.com (52.135.46.212) by MN2PR12MB4142.namprd12.prod.outlook.com (52.135.51.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.25; Sat, 1 May 2021 01:58:19 +0000 Received: from BL0PR12MB4948.namprd12.prod.outlook.com ([fe80::70f5:99ed:65a1:c033]) by BL0PR12MB4948.namprd12.prod.outlook.com ([fe80::70f5:99ed:65a1:c033%5]) with mapi id 15.20.4065.027; Sat, 1 May 2021 01:58:19 +0000 From: Felix Kuehling To: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [RFC PATCH 02/17] x86/configs: CRIU update debug rock defconfig Date: Fri, 30 Apr 2021 21:57:37 -0400 Message-Id: <20210501015752.888-3-Felix.Kuehling@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210501015752.888-1-Felix.Kuehling@amd.com> References: <20210501015752.888-1-Felix.Kuehling@amd.com> X-Originating-IP: [165.204.54.211] X-ClientProxiedBy: YT1PR01CA0037.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:2e::6) To BL0PR12MB4948.namprd12.prod.outlook.com (2603:10b6:208:1cc::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (165.204.54.211) by YT1PR01CA0037.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:2e::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.25 via Frontend Transport; Sat, 1 May 2021 01:58:18 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 29435bf7-11da-4162-da4c-08d90c4497b9 X-MS-TrafficTypeDiagnostic: MN2PR12MB4142: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5516; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FbL+H24mCIU5LeR6o1UistdDhklj/0K8yNFp5KZFu61CEVaI8BnxbyXFC7rBSz1qxXFv3I+xpYMgXx+5KmrMr6GX6u/jSS8aZnkPCCq5r3Prza/h6PLrAygQ1jUrKSP9vkxaAdEw7bqsoAznFWoEs1OTtLt+J5t6kaove2KFKeqnNOgSJ/s1WLpxHoJXxRwfr6BvCuLxMSc9yaS7fp/25MLwx3TSxKhTtafNMW41TBq98CaxRJl7/Ofqv+vIMPIz1LuBCJCGKnK+7wTTSy+Ic2mMvWaTSo+HDWpldS18wwxwRm1jfQk7x4TyQPcrWaU4pBP52XdfdvkldEBMQI2E+Ei3jQD8jBkqfutAzPMmukjcVDF+sFFAZhacoCw36PkHBSfizdPupzgQ3wVmfAsvhTHdVYzLKThpGnPvXSkc47A/9V/Ur5oiEcTickqzfpSrWQOlM2Vt23IeLVEgpjcgtNFVDQEFZUinUCjx0sJOViZm44tMWLlhMypaoAVoiQyaTR2D2UrKnSBce0rSd+GvMIp+Lq0xeknM/Vzztwx4FjtAxhvAxOmfExqPJQO+pdd66DqXLLzVgbhxyMnHwPnPDmJFsYIayuw6WdEMR7RSiXuL88zgBhj9TjpT9+/Jok85yOMPFsJXXN5BOXUiK3iqRVWQ+XTJ4UWftPhPEbW0igOZQGPzbYWT56wcM/SC1r2/ X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BL0PR12MB4948.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(346002)(366004)(396003)(39860400002)(136003)(15650500001)(66556008)(6506007)(66574015)(2616005)(66946007)(66476007)(52116002)(956004)(38100700002)(6512007)(450100002)(4326008)(8676002)(8936002)(478600001)(2906002)(6486002)(86362001)(26005)(186003)(16526019)(83380400001)(5660300002)(1076003)(36756003)(6666004)(316002)(38350700002)(69590400013); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: ATNJQEA4FwEpTSMGQcWvoBb/Z8sD8xqA5eSOt88OoM7olliGoKcK9wM8kVW4bRlqn/ba4ju8CjQTFgpzT2OcI+EJ6DNhS6XYlM7ksoA/rmooZZ1mTL27tMZvkgBMGdAsVZikmg3HNlgQOBHL0epk2CAYpT+6rUtzaV0sa01Ev/fwsFR14TdzGcv3/jRgwxsjGzueuP95vG0QvEcC28jRXRmzFIjhpo8V5LmyvPbEo2TGQ/jGuVkisGRqsFcxSg7w3o5PI/X5Bm5xdw343sCA/5BerwjA9sy/Y6ZQ9PG6dO+Wf2ylpAnOY9yER4OGk9DxbKDJj/hcb7VcXdXUqQ55+UGZyy9izvQ6cloX3+OITTohKsN2zBonleiO5TSIoWd9ztnPfibNdRBV2qLuwu4BvPMvpvp3zt2XeClhS8WfUFMesVcSPFxBVNlJu4SFA8vxVwwZxVxaunOlmw72jj1x8HOFKV4wz1ZN65RsLU8D/GzhhauMTUSZsVTyGfpRHyidHTb6hpbpVUeGlL/UIRRC4iuJJ7MK0IqlSTHAF1C2F8BfGK3S3xbPe0vur+nw2T9hncN+vJWSVS8RnMoAmM29NvVamGwGO7tL7ks0Y4dVsVX945OdSDIXg0owWDJot8jtRWre3pkJp3xwF2S3r8miB5Q4+n5IOwk4OlsSvee3HWWzkvhv3KHqoViT041IO/NdZ70PbPgHFndMbuXYgGEJf3BRbYIeupyGrgnrvKsfPnrrPX2cHLNX3IMjV4B3cMFUhFiO1HKZq8sM5Ol6TiDqRcTtXI7vtcdtJrSYH2P9RMPUv+vLDTOXqKv9t0FQD+8Aiy9Fh6c11ZOzVTNwvNa5QHlzLoMeCfvXQIOK2xoXqxGkig0OCPxAV40Nj4IOrLs4N4S7yVF4/1w9VwAEJ/B+0X+JxyO2+zJZAtykqIZrZgXyjDGz5/9FGF+CxWiB9nX/d6W3pvYj1JnGqfPQ5CQX/QU0713NmHbf+mIsk7ju+1b11HT5ONaaZPeV9gcZzdbCctnET04Hy17kkb3gzgFFZVAA6f8utQ18B8GcQt2BfL13P2RnWhSGKgtoizeOMbAXLX6XUnbBSpyQVg65MRCV1s50AyUR69w64edhE2fnonHBN12bBUJmidBwY+l03DmZi86zTESgYBdC5necOz7Fg123bDn2tsLNg8/BSRKiU/Grfjj4/sdPzUQv9ZlK9f6Nu1+apYABZtyEcwAAavmblWoPJj+bayeK15rj4Qfg6KMWlyBpjNG80Z0+ul9zaRBR/XuPCJXnvBjkCBG/2oX6l5vozuDdDbIPEatLUP9MA7zO5u5ykAN2h9qod2LjRSIe X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 29435bf7-11da-4162-da4c-08d90c4497b9 X-MS-Exchange-CrossTenant-AuthSource: BL0PR12MB4948.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 May 2021 01:58:19.4157 (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: k9T6LSRofrCwVPONYEzVQp6Qb2J48C5mF4VWADWcHUpx4ePhoCFrqlV+peqz7eiY2EHYnVYz9INbhBllkxMlIQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4142 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: Rajneesh Bhardwaj Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Rajneesh Bhardwaj - Update debug config for Checkpoint-Restore (CR) support - Also include necessary options for CR with docker containers. Signed-off-by: Rajneesh Bhardwaj Change-Id: Ie993f9b99553d46c48c60a5a1c054de0d923bc86 --- arch/x86/configs/rock-dbg_defconfig | 53 ++++++++++++++++++----------- 1 file changed, 34 insertions(+), 19 deletions(-) diff --git a/arch/x86/configs/rock-dbg_defconfig b/arch/x86/configs/rock-dbg_defconfig index 54688993d6e2..87951da7de6a 100644 --- a/arch/x86/configs/rock-dbg_defconfig +++ b/arch/x86/configs/rock-dbg_defconfig @@ -236,6 +236,7 @@ CONFIG_BPF_SYSCALL=y CONFIG_ARCH_WANT_DEFAULT_BPF_JIT=y # CONFIG_BPF_PRELOAD is not set # CONFIG_USERFAULTFD is not set +CONFIG_USERFAULTFD=y CONFIG_ARCH_HAS_MEMBARRIER_SYNC_CORE=y CONFIG_KCMP=y CONFIG_RSEQ=y @@ -994,6 +995,11 @@ CONFIG_PACKET_DIAG=y CONFIG_UNIX=y CONFIG_UNIX_SCM=y CONFIG_UNIX_DIAG=y +CONFIG_SMC_DIAG=y +CONFIG_XDP_SOCKETS_DIAG=y +CONFIG_INET_MPTCP_DIAG=y +CONFIG_TIPC_DIAG=y +CONFIG_VSOCKETS_DIAG=y # CONFIG_TLS is not set CONFIG_XFRM=y CONFIG_XFRM_ALGO=y @@ -1031,15 +1037,17 @@ CONFIG_SYN_COOKIES=y # CONFIG_NET_IPVTI is not set # CONFIG_NET_FOU is not set # CONFIG_NET_FOU_IP_TUNNELS is not set -# CONFIG_INET_AH is not set -# CONFIG_INET_ESP is not set -# CONFIG_INET_IPCOMP is not set -CONFIG_INET_TUNNEL=y -CONFIG_INET_DIAG=y -CONFIG_INET_TCP_DIAG=y -# CONFIG_INET_UDP_DIAG is not set -# CONFIG_INET_RAW_DIAG is not set -# CONFIG_INET_DIAG_DESTROY is not set +CONFIG_INET_AH=m +CONFIG_INET_ESP=m +CONFIG_INET_IPCOMP=m +CONFIG_INET_ESP_OFFLOAD=m +CONFIG_INET_TUNNEL=m +CONFIG_INET_XFRM_TUNNEL=m +CONFIG_INET_DIAG=m +CONFIG_INET_TCP_DIAG=m +CONFIG_INET_UDP_DIAG=m +CONFIG_INET_RAW_DIAG=m +CONFIG_INET_DIAG_DESTROY=y CONFIG_TCP_CONG_ADVANCED=y # CONFIG_TCP_CONG_BIC is not set CONFIG_TCP_CONG_CUBIC=y @@ -1064,12 +1072,14 @@ CONFIG_TCP_MD5SIG=y CONFIG_IPV6=y # CONFIG_IPV6_ROUTER_PREF is not set # CONFIG_IPV6_OPTIMISTIC_DAD is not set -CONFIG_INET6_AH=y -CONFIG_INET6_ESP=y -# CONFIG_INET6_ESP_OFFLOAD is not set -# CONFIG_INET6_ESPINTCP is not set -# CONFIG_INET6_IPCOMP is not set -# CONFIG_IPV6_MIP6 is not set +CONFIG_INET6_AH=m +CONFIG_INET6_ESP=m +CONFIG_INET6_ESP_OFFLOAD=m +CONFIG_INET6_IPCOMP=m +CONFIG_IPV6_MIP6=m +CONFIG_INET6_XFRM_TUNNEL=m +CONFIG_INET_DCCP_DIAG=m +CONFIG_INET_SCTP_DIAG=m # CONFIG_IPV6_ILA is not set # CONFIG_IPV6_VTI is not set CONFIG_IPV6_SIT=y @@ -1126,8 +1136,13 @@ CONFIG_NF_CT_PROTO_UDPLITE=y # CONFIG_NF_CONNTRACK_SANE is not set # CONFIG_NF_CONNTRACK_SIP is not set # CONFIG_NF_CONNTRACK_TFTP is not set -# CONFIG_NF_CT_NETLINK is not set -# CONFIG_NF_CT_NETLINK_TIMEOUT is not set +CONFIG_COMPAT_NETLINK_MESSAGES=y +CONFIG_NF_CT_NETLINK=m +CONFIG_NF_CT_NETLINK_TIMEOUT=m +CONFIG_NF_CT_NETLINK_HELPER=m +CONFIG_NETFILTER_NETLINK_GLUE_CT=y +CONFIG_SCSI_NETLINK=y +CONFIG_QUOTA_NETLINK_INTERFACE=y CONFIG_NF_NAT=m CONFIG_NF_NAT_REDIRECT=y CONFIG_NF_NAT_MASQUERADE=y @@ -1971,7 +1986,7 @@ CONFIG_NETCONSOLE_DYNAMIC=y CONFIG_NETPOLL=y CONFIG_NET_POLL_CONTROLLER=y # CONFIG_RIONET is not set -# CONFIG_TUN is not set +CONFIG_TUN=y # CONFIG_TUN_VNET_CROSS_LE is not set CONFIG_VETH=y # CONFIG_NLMON is not set @@ -3955,7 +3970,7 @@ CONFIG_MANDATORY_FILE_LOCKING=y CONFIG_FSNOTIFY=y CONFIG_DNOTIFY=y CONFIG_INOTIFY_USER=y -# CONFIG_FANOTIFY is not set +CONFIG_FANOTIFY=y CONFIG_QUOTA=y CONFIG_QUOTA_NETLINK_INTERFACE=y # CONFIG_PRINT_QUOTA_WARNING is not set From patchwork Sat May 1 01:57:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Kuehling X-Patchwork-Id: 12234567 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=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 5944FC433ED for ; Sat, 1 May 2021 01:58:35 +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 EF2E9613F7 for ; Sat, 1 May 2021 01:58:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EF2E9613F7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none 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 52C246F627; Sat, 1 May 2021 01:58:24 +0000 (UTC) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2059.outbound.protection.outlook.com [40.107.92.59]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6A0DC6F624; Sat, 1 May 2021 01:58:22 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=K3rmGNt2cXa1iIrV9+RWh+dqtGMqt38ECGuXO6qKLO7TwTw4NoI4kBgtVaj2ai/aoBgb1tDpiFskEL1AJCShL7FWz7xRkilVnDtKd4+Lr6YriVeGWjuRomWnd+Pmyye/8DgxnY5vvKxqusnnd0BQD6ibAqTUTtjFt7zyD+IX8UzB3BRLBzmC9Uqa9F48E+1vho/WvCDI2vfAER6RTBD37SXizWLLe+oBvF2HUWIMa7b5x/y7qBFjuezUTJFR4TZu6KEvpkJ4I2wL5LAHijC9e7VT4qOtFaEaozKh62sTjUj7rpWN9kS6zh1pYA4yRTYy9nGQ+r5xeMZXzxQmnKAhnQ== 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=PZtBg1o6o4VoLsm3mvQqAex5ekmH5ZeWXTZahq+fP5o=; b=S2hwC5rfwVi6mhK2M78w3YVKWsJuvCsLu3CRxWE0zcJZcnVBvziwNQS3+aanw3Nn5sPyy9u5bJ8BeC8dM4br+/EN3aSSaT03yDJBvLIGtRblPd5/QWINXUUvtcGivado9v//J8Z2HlY1ohut0+Ce2syXzdLNWGP/CEg4yl21hOqgfwXQ5eDPvALBctqMYbEMuKErxjqVb/3vCC4nZYFowEjKRyhZBNoYEgV7YO3YRSeOA3yynvUd+6nCelMhp5OB7FlxO9LIOcWG3JoGKDXu0Fbn4PU7iamdyAlhMVEwOsUA+Ail2D6zAmrz8hUw5XrHjmeiBwsDo9rJkU3PmIZ8Rg== 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=PZtBg1o6o4VoLsm3mvQqAex5ekmH5ZeWXTZahq+fP5o=; b=S7if88dS3Drd5CCVI6YNQAld1oi65u/wOTVc8hlZnZ4xNLWI1KJC2QEQrnw8hc5j3h9gimA4E/rKrJ/b10nT/CzozenEL1qLv/gsdVsv6lPZytOjRf6s0Nq7KLDTdJlbJ6Ot0WOM+CUhqzy7LUoLLM70Bjv0n2QKrl3iPvBcuHU= 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 BL0PR12MB4948.namprd12.prod.outlook.com (52.135.46.212) by MN2PR12MB4142.namprd12.prod.outlook.com (52.135.51.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.25; Sat, 1 May 2021 01:58:20 +0000 Received: from BL0PR12MB4948.namprd12.prod.outlook.com ([fe80::70f5:99ed:65a1:c033]) by BL0PR12MB4948.namprd12.prod.outlook.com ([fe80::70f5:99ed:65a1:c033%5]) with mapi id 15.20.4065.027; Sat, 1 May 2021 01:58:20 +0000 From: Felix Kuehling To: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [RFC PATCH 03/17] drm/amdkfd: CRIU Introduce Checkpoint-Restore APIs Date: Fri, 30 Apr 2021 21:57:38 -0400 Message-Id: <20210501015752.888-4-Felix.Kuehling@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210501015752.888-1-Felix.Kuehling@amd.com> References: <20210501015752.888-1-Felix.Kuehling@amd.com> X-Originating-IP: [165.204.54.211] X-ClientProxiedBy: YT1PR01CA0037.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:2e::6) To BL0PR12MB4948.namprd12.prod.outlook.com (2603:10b6:208:1cc::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (165.204.54.211) by YT1PR01CA0037.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:2e::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.25 via Frontend Transport; Sat, 1 May 2021 01:58:19 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 51b3a221-f570-478b-e815-08d90c449847 X-MS-TrafficTypeDiagnostic: MN2PR12MB4142: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:475; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +wIisM7NDG19Qy9CUbkOWQNs8J/ktocR1RZtHKPljCf2UEGE8ltle3CCtXiOOZMlT9Prge48F7R5xHuI4WQgOOLdi08KzA9z/9fNbibdZpGRA4ex8esAg3IU6TPAPqjPMl06OJadEYMA/i7P4tmJ/ZMUgYthcSkeC5ItTI2Mgm/nnEUgj53SPlHKOc9XfO64Z1Duv4JqQMJ0KFx9hZcZ1DyXYz9Adpj7tVTU5f3kkbm5VTnraykwftgmG/VrdtPOH8MuDYB1WiI8AKf3Y7ROs3t5ILNSbmuUoCOCKvLA90W/lj7al+VPIdzhJWLiILwH3nKFSYfFNcWuMli7CQNj/nIzYSOFpRwA+e586+smAMJNWRHAqFeDycTb7BiPRKFyUjH39XsnMcK+7709Zr9j0cdEbV1TRr0sbOcCDUveHmyBIPPH4qg8z/4ZPa2Pe8M/pI95MSAXOkWcu5XxJB/eHsdczIeQbEorro4E9n53BT3EOhBBpSJ004cBk6nh9zjRdnK13mJg3LJr1MbecbV/InnK7d0Uo2mw6a5f3dS7u2UkMpEUeF5TwEdWLAlk3YQsSMTH0SKJ7WWZWnymcKpqSfI26FqW1STtWwFInmv/VmsVfpjNQU3yK3uwI7Di9TgcMtCto3gAA+mW4DgeHA+T3VGHIo+pNMJm8l3dEeqxNcT+8r4Z9yHJq9MCU97c/gIl X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BL0PR12MB4948.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(346002)(366004)(396003)(39860400002)(136003)(66556008)(6506007)(54906003)(2616005)(66946007)(66476007)(52116002)(956004)(38100700002)(6512007)(450100002)(4326008)(8676002)(8936002)(478600001)(2906002)(6486002)(86362001)(26005)(186003)(16526019)(83380400001)(5660300002)(1076003)(36756003)(6666004)(316002)(38350700002)(69590400013); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: PLj6MVzJd7aY2/Zngos6326drFZ3/ijehLwjNX83DyGtKmpt7fREvFHjqpe1pP/6FzPis7DpvMr9nR6jJQL/gTFY4oze2jMb0MkpFZW4Vw5Ey+vvkMVtccq4HTS8/2Bq1V6U0PqJyR3SEYAnt6LvXaufCVR2lPVAIWXeJIwkCzi6H3bvprO9OyhFOI1i+o+req2ain/Gad2h0v0gNJEtC4jkzMTfvCJtRJo8AZlaP1BrqKkBQoduuLW6iaUh2lnDarwsdR937A/wJ1UhnYfL7ZdJwQjuroouDj/OFRsj/uQpgLLwq5YlDKbrmLFtlfQWjFK3iOo8uC0tZa2t6fHd0FgXNJv7g9RrOORfqBpaKIexTdBG6UTXq+CfzBBqVJ2aFytLrtzllSseE7rU/UCM9mYZSTPABrSN+JBGVjI+aJxbJJ0eRiUj0eiSRKuivodoZdw+MIkYcdLWZoObe6b/qWFWMcPr9TB7TQDsONAKYnU6bFf4vB34FpSYtZh1xv1ie8N0oXZC5lxyvub/hhmWtiX7peEl59v3BrjXCmnE/Ko+7lvy9oLqmhZY+MQZmRbdDdNfAojRLP5D2DYq1iM7LhS9Qebr/WTAaxRaZbBpl+y7WXtqENZ5yLGmqPqd8HqtSoMnoc3PTuqJZUkcSkqHafwea2OP7j9I5P9Uqu4Qt8Etwpmg3jXGE4S6kO0yuLYQgshbb7Br3/ofLxfoXQZoY73D1wChlbE3ISPKJi85Bw9D+BXo3kyU/HvY8Kphu5CQlj7T7kwl/K8H6YAWotiXVx/1QxTV20kacXCxraHKMmyJYn20/Dltd6IZ+SYfVm5XrFl1AKhWXxgw122qdE5KB5W6SiTrP9WAyFzaoF5lz5mxjsT8p4suty6tC5HUOukZ1iDmwgr4JPYzM2vjs6G1wBfbvOOtZMDeCQt6QlX0GSsBoMVsPlcHpsKhRhY96K6lQVfi30ldlyaG5M5Zu3iZjj9NtCTeSYiSykFjIq0Q8OKszpEoUNT1WgyBUMldIif1ISphhpviAnX9dU4nREF3l8DvQ3qDWQyfAut+JMPqRiayFimFNgeWyIrU4DDW+1yx3EALViIKcpyrVJ1EIsr/iNlJiryeDbte7JZPgSm9Xp3nK6hSR1c4QAugqfpRqdCyx/b9XlXu6aZRN8w8NuCyHbJi1psizwnKu/7yr3y1W5tn3txFHDzyCAfvRRYgEPSeO73rsEAxBUz7cVdnDnVzOx5wBi5/bd5SLCC8POERGuQQRL4g01MQ3qcvUMoLh05BFR6Vi4gv7nysLbLCIYFLcCl7LMEmb53DqKLs/T2HK2c/xrM1/iJtKxWl+fPsze5D X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 51b3a221-f570-478b-e815-08d90c449847 X-MS-Exchange-CrossTenant-AuthSource: BL0PR12MB4948.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 May 2021 01:58:20.5627 (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: wssZp2olIJkgU2q1a+L4OmnvRz3sMllG91qVTUDINqoW5/Nx0p19Vgm8ZBzExTcPS75KxiutM8UXpve+yj2OMA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4142 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: David Yat Sin , Rajneesh Bhardwaj Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Rajneesh Bhardwaj Checkpoint-Restore in userspace (CRIU) is a powerful tool that can snapshot a running process and later restore it on same or a remote machine but expects the processes that have a device file (e.g. GPU) associated with them, provide necessary driver support to assist CRIU and its extensible plugin interface. Thus, In order to support the Checkpoint-Restore of any ROCm process, the AMD Radeon Open Compute Kernel driver, needs to provide a set of new APIs that provide necessary VRAM metadata and its contents to a userspace component (CRIU plugin) that can store it in form of image files. This introduces some new ioctls which will be used to checkpoint-Restore any KFD bound user process. KFD doesn't allow any arbitrary ioctl call unless it is called by the group leader process. Since these ioctls are expected to be called from a KFD criu plugin which has elevated ptrace attached priviledges and CAP_SYS_ADMIN capabilities attached with the file descriptors so modify KFD to allow such calls. Signed-off-by: David Yat Sin Signed-off-by: Rajneesh Bhardwaj (cherry picked from commit 72f4907135aed9c037b9f442a6055b51733b518a) (cherry picked from commit 33ff4953c5352f51d57a77ba8ae6614b7993e70d) Change-Id: I1b25f6f65ad44b897752ac2c771a95157d0b1130 --- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 60 ++++++++++++- drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 28 ++++++ include/uapi/linux/kfd_ioctl.h | 110 ++++++++++++++++++++++- 3 files changed, 196 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c index 059c3f1ca27d..1fa2ba34a429 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include "kfd_priv.h" @@ -1802,6 +1803,37 @@ static int kfd_ioctl_svm(struct file *filep, struct kfd_process *p, void *data) return -EPERM; } #endif +static int kfd_ioctl_criu_dumper(struct file *filep, + struct kfd_process *p, void *data) +{ + pr_info("Inside %s\n",__func__); + + return 0; +} + +static int kfd_ioctl_criu_restorer(struct file *filep, + struct kfd_process *p, void *data) +{ + pr_info("Inside %s\n",__func__); + + return 0; +} + +static int kfd_ioctl_criu_helper(struct file *filep, + struct kfd_process *p, void *data) +{ + pr_info("Inside %s\n",__func__); + + return 0; +} + +static int kfd_ioctl_criu_resume(struct file *filep, + struct kfd_process *p, void *data) +{ + pr_info("Inside %s\n",__func__); + + return 0; +} #define AMDKFD_IOCTL_DEF(ioctl, _func, _flags) \ [_IOC_NR(ioctl)] = {.cmd = ioctl, .func = _func, .flags = _flags, \ @@ -1906,6 +1938,18 @@ static const struct amdkfd_ioctl_desc amdkfd_ioctls[] = { AMDKFD_IOCTL_DEF(AMDKFD_IOC_SET_XNACK_MODE, kfd_ioctl_set_xnack_mode, 0), + + AMDKFD_IOCTL_DEF(AMDKFD_IOC_CRIU_DUMPER, + kfd_ioctl_criu_dumper, KFD_IOC_FLAG_PTRACE_ATTACHED), + + AMDKFD_IOCTL_DEF(AMDKFD_IOC_CRIU_RESTORER, + kfd_ioctl_criu_restorer, KFD_IOC_FLAG_ROOT_ONLY), + + AMDKFD_IOCTL_DEF(AMDKFD_IOC_CRIU_HELPER, + kfd_ioctl_criu_helper, KFD_IOC_FLAG_PTRACE_ATTACHED), + + AMDKFD_IOCTL_DEF(AMDKFD_IOC_CRIU_RESUME, + kfd_ioctl_criu_resume, KFD_IOC_FLAG_ROOT_ONLY), }; #define AMDKFD_CORE_IOCTL_COUNT ARRAY_SIZE(amdkfd_ioctls) @@ -1920,6 +1964,7 @@ static long kfd_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) char *kdata = NULL; unsigned int usize, asize; int retcode = -EINVAL; + bool ptrace_attached = false; if (nr >= AMDKFD_CORE_IOCTL_COUNT) goto err_i1; @@ -1945,7 +1990,15 @@ static long kfd_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) * processes need to create their own KFD device context. */ process = filep->private_data; - if (process->lead_thread != current->group_leader) { + + rcu_read_lock(); + if ((ioctl->flags & KFD_IOC_FLAG_PTRACE_ATTACHED) && + ptrace_parent(process->lead_thread) == current) + ptrace_attached = true; + rcu_read_unlock(); + + if (process->lead_thread != current->group_leader + && !ptrace_attached) { dev_dbg(kfd_device, "Using KFD FD in wrong process\n"); retcode = -EBADF; goto err_i1; @@ -1960,6 +2013,11 @@ static long kfd_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) goto err_i1; } + /* KFD_IOC_FLAG_ROOT_ONLY is only for CAP_SYS_ADMIN */ + if (unlikely((ioctl->flags & KFD_IOC_FLAG_ROOT_ONLY) && + !capable(CAP_SYS_ADMIN))) + return -EACCES; + if (cmd & (IOC_IN | IOC_OUT)) { if (asize <= sizeof(stack_kdata)) { kdata = stack_kdata; diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h index 64552f6b8ba4..a494d61543af 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h +++ b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h @@ -121,7 +121,35 @@ */ #define KFD_QUEUE_DOORBELL_MIRROR_OFFSET 512 +/** + * enum kfd_ioctl_flags - KFD ioctl flags + * Various flags that can be set in &amdkfd_ioctl_desc.flags to control how + * userspace can use a given ioctl. + */ +enum kfd_ioctl_flags { + /** + * @KFD_IOC_FLAG_ROOT_ONLY: + * Certain KFD ioctls such as AMDKFD_IOC_CRIU_RESTORER can potentially + * perform privileged operations and load arbitrary data into MQDs and + * eventually HQD registers when the queue is mapped by HWS. In order to + * prevent this we should perform additional security checks. In other + * cases, certain ioctls such as AMDKFD_IOC_CRIU_RESUME might be called + * by an external process e.g. CRIU restore process, for each resuming + * tasks and thus require elevated privileges. + * + * This is equivalent to callers with the SYSADMIN capability. + */ + KFD_IOC_FLAG_ROOT_ONLY = BIT(0), + /** + * @KFD_IOC_FLAG_PTRACE_ATTACHED: + * Certain KFD ioctls such as AMDKFD_IOC_CRIU_HELPER and + * AMDKFD_IOC_CRIU_DUMPER are expected to be called during a Checkpoint + * operation triggered by CRIU. Since, these are expected to be called + * from a PTRACE attched context, we must authenticate these. + */ + KFD_IOC_FLAG_PTRACE_ATTACHED = BIT(1), +}; /* * Kernel module parameter to specify maximum number of supported queues per * device diff --git a/include/uapi/linux/kfd_ioctl.h b/include/uapi/linux/kfd_ioctl.h index 3cb5b5dd9f77..9c8a77a0ce0a 100644 --- a/include/uapi/linux/kfd_ioctl.h +++ b/include/uapi/linux/kfd_ioctl.h @@ -467,6 +467,102 @@ struct kfd_ioctl_smi_events_args { __u32 anon_fd; /* from KFD */ }; +struct kfd_criu_devinfo_bucket { + __u32 user_gpu_id; + __u32 actual_gpu_id; + __u32 drm_fd; +}; + +struct kfd_criu_bo_buckets { + __u64 bo_addr; /* from KFD */ + __u64 bo_size; /* from KFD */ + __u64 bo_offset;/* from KFD */ + __u64 user_addr; /* from KFD */ + __u32 bo_alloc_flags;/* from KFD */ + __u32 gpu_id;/* from KFD */ + __u32 idr_handle;/* from KFD */ +}; + +struct kfd_criu_q_bucket { + __u64 q_address; + __u64 q_size; + __u64 read_ptr_addr; + __u64 write_ptr_addr; + __u64 doorbell_off; + __u64 eop_ring_buffer_address; /* Relevant only for VI */ + __u64 ctx_save_restore_area_address; /* Relevant only for VI */ + __u64 queues_data_offset; + __u32 gpu_id; + __u32 type; + __u32 format; + __u32 q_id; + __u32 priority; + __u32 q_percent; + __u32 doorbell_id; + __u32 is_gws; /* TODO Implement me */ + __u32 sdma_id; /* Relevant only for sdma queues*/ + __u32 eop_ring_buffer_size; /* Relevant only for VI */ + __u32 ctx_save_restore_area_size; /* Relevant only for VI */ + __u32 ctl_stack_size; /* Relevant only for VI */ + __u32 cu_mask_size; + __u32 mqd_size; +}; + +struct kfd_criu_ev_bucket { + __u32 event_id; + __u32 auto_reset; + __u32 type; + __u32 signaled; + + union { + struct kfd_hsa_memory_exception_data memory_exception_data; + struct kfd_hsa_hw_exception_data hw_exception_data; + }; +}; + +struct kfd_ioctl_criu_dumper_args { + __u64 num_of_bos; + __u64 kfd_criu_bo_buckets_ptr; + __u64 kfd_criu_q_buckets_ptr; + __u64 kfd_criu_ev_buckets_ptr; + __u64 kfd_criu_devinfo_buckets_ptr; + __u64 queues_data_size; + __u64 queues_data_ptr; + __u64 event_page_offset; + __u32 num_of_queues; + __u32 num_of_devices; + __u32 num_of_events; +}; + +struct kfd_ioctl_criu_restorer_args { + __u64 handle; /* from KFD */ + __u64 num_of_bos; + __u64 kfd_criu_bo_buckets_ptr; + __u64 restored_bo_array_ptr; + __u64 kfd_criu_q_buckets_ptr; + __u64 kfd_criu_ev_buckets_ptr; + __u64 kfd_criu_devinfo_buckets_ptr; + __u64 queues_data_size; + __u64 queues_data_ptr; + __u64 event_page_offset; + __u32 num_of_devices; + __u32 num_of_queues; + __u32 num_of_events; +}; + +struct kfd_ioctl_criu_helper_args { + __u64 num_of_bos; /* from KFD */ + __u64 queues_data_size; + __u32 task_pid; + __u32 num_of_devices; + __u32 num_of_queues; /* from KFD */ + __u32 num_of_events; /* from KFD */ +}; + +struct kfd_ioctl_criu_resume_args { + __u32 pid; /* to KFD */ +}; + /* Register offset inside the remapped mmio page */ enum kfd_mmio_remap { @@ -740,7 +836,19 @@ struct kfd_ioctl_set_xnack_mode_args { #define AMDKFD_IOC_SET_XNACK_MODE \ AMDKFD_IOWR(0x21, struct kfd_ioctl_set_xnack_mode_args) +#define AMDKFD_IOC_CRIU_DUMPER \ + AMDKFD_IOWR(0x22, struct kfd_ioctl_criu_dumper_args) + +#define AMDKFD_IOC_CRIU_RESTORER \ + AMDKFD_IOWR(0x23, struct kfd_ioctl_criu_restorer_args) + +#define AMDKFD_IOC_CRIU_HELPER \ + AMDKFD_IOWR(0x24, struct kfd_ioctl_criu_helper_args) + +#define AMDKFD_IOC_CRIU_RESUME \ + AMDKFD_IOWR(0x25, struct kfd_ioctl_criu_resume_args) + #define AMDKFD_COMMAND_START 0x01 -#define AMDKFD_COMMAND_END 0x22 +#define AMDKFD_COMMAND_END 0x26 #endif From patchwork Sat May 1 01:57:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Kuehling X-Patchwork-Id: 12234565 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=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 2AAE7C433ED for ; Sat, 1 May 2021 01:58:32 +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 DBBD261407 for ; Sat, 1 May 2021 01:58:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DBBD261407 Authentication-Results: mail.kernel.org; dmarc=fail (p=none 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 D38656F628; Sat, 1 May 2021 01:58:23 +0000 (UTC) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2059.outbound.protection.outlook.com [40.107.92.59]) by gabe.freedesktop.org (Postfix) with ESMTPS id A5A716F626; Sat, 1 May 2021 01:58:22 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mah4WKruAGrZT2q8570QDlIltgEat2swEDoRlqXc/ZnTBWXlW37NtMD+fQ3Vj9whV8tEbyuAK56dl/T/IQAOekaINP/ZJe4F0R9w3RQB8zQsOAQP0q6omj37iNY821PCk6N51DHH6kmRXxoFQ0bwrVeFN8eX8d3wSvx8GWOWSlWkTamw6CeRzyuUs62RPLR1cOH3KApOM/xq39Xw21zZ7FnWt0iJWzKxzop8Ge87+avVM/GxPMUH9m+IeNx59KKxGEBy5lO8AHQEs5tGcMeah844DH/288ddCnHDYr7QzFIpciba+F/AU2HMd1BsL76UWk7RZiaPgN3Gq+02V1zf1Q== 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=pGhrWjEFxlwMUTkjxR1KzhIwJrjxhLYs9HCH12R689c=; b=nGPXN0CTd/m5r0H9gFVqZ8SKeX8dQJbS2iurmjK6ssqvc7DVWp1V8SJ0IKS//JHBgaUaPXQdydT6LJl4PeS1bKV+RGLPqJMMRaKF3XFYPDf/9hsALkslAkS6y3eEIyFvL8byXpMw9+VVzQRXvCfO95J9k6YJ0nxEgpi8fnso+ayqZlYcB6aACOue4R3cQSpqI/9HUbfRRlcASX/ljHJczdoRFpAetjQtQSMxq3r9tZkhj7H2HE4cTp4c4zX1blxyJkcuvjBcLOU6dZm2GqdWuiLKP9NiWNGBvLzpgTqV1Mu1YPkqh95lGIlr1jcsQy1y9VD5Ib8T5JtHHTjQxL+miQ== 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=pGhrWjEFxlwMUTkjxR1KzhIwJrjxhLYs9HCH12R689c=; b=Fbvv/Pn/5kZppNajpJK3lFth1PxlTCa82Bywy89jvBd8C0EZKvoc+P68jRIVaSYF87SKQNgKwJkbc+HqeIpRFBu2XWdFYr3gSYu2V083zJOeIEfMglyH0apocmEG7y6VKkX5VzkEJTN8xgqxpqVjo+epwIkxBQtSV4ljkBVvVOI= 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 BL0PR12MB4948.namprd12.prod.outlook.com (52.135.46.212) by MN2PR12MB4142.namprd12.prod.outlook.com (52.135.51.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.25; Sat, 1 May 2021 01:58:21 +0000 Received: from BL0PR12MB4948.namprd12.prod.outlook.com ([fe80::70f5:99ed:65a1:c033]) by BL0PR12MB4948.namprd12.prod.outlook.com ([fe80::70f5:99ed:65a1:c033%5]) with mapi id 15.20.4065.027; Sat, 1 May 2021 01:58:21 +0000 From: Felix Kuehling To: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [RFC PATCH 04/17] drm/amdkfd: CRIU Implement KFD helper ioctl Date: Fri, 30 Apr 2021 21:57:39 -0400 Message-Id: <20210501015752.888-5-Felix.Kuehling@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210501015752.888-1-Felix.Kuehling@amd.com> References: <20210501015752.888-1-Felix.Kuehling@amd.com> X-Originating-IP: [165.204.54.211] X-ClientProxiedBy: YT1PR01CA0037.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:2e::6) To BL0PR12MB4948.namprd12.prod.outlook.com (2603:10b6:208:1cc::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (165.204.54.211) by YT1PR01CA0037.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:2e::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.25 via Frontend Transport; Sat, 1 May 2021 01:58:20 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 273b963b-dac6-433a-0ac8-08d90c4498f4 X-MS-TrafficTypeDiagnostic: MN2PR12MB4142: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:132; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Tlauydz1FfHjHGqe8UpSSSldvLJTEYBGLMa+gNck+BZMbhqNP2Ygv9BszpgxCff2OMhXjnYfOQ8c+uxVyRw60vdeGUXD/NAROiIu3irdK01p349Vo0z440zC2swzIlIGIVhBoA1moj9xBjVHG4NZupjONpsvmCtcmF8yjN7G1D5G/viCz7U4ecy4VsbaBCsAndgnLyZpmUcpcUwKWc3z+C+s8+C3HvtYsNje9u+7fhVQjBMXNEZ+bTgkoArW46lydwBZkoqDDfajTmqt2bfJ0tSjn5F78CBFYkfvgP4M2vB5DdGenIjELKdXhWp6jhgoEsUzLKFDWRbxBdxSGVkViNjbMVQGVef9+l6HD3vJWqsrGcgUevVoPZsjPSb9zhmYnuuZ9KyNnKyCWBp4VnORlI8FPz/fxML27rqw43P/IUJbieUcpHKd/hQvTEC+PtDfQKIFYYtI5tRgpW+gePoavWnvFV+Mh6c5aiPNAMgOdr2qifX4IIdaa+53OhjhoY9ejKpJYP4OlDERciqyIqtvAAFb3z0lRUyOo8fokNJjnbtk2LcmDRxR3mbyiWazG0iSA8ppVGruBPRHbyyCaTZpPadtgUG1BW2XmpN36GL6WeeEeNOuVWVn5uyU0QuTY8355KJA8x+hTShnpJyxDxiMTok54AXFoT0FRWZyyKhCxY+tg9eWvGr9hKgdLDM30gnX X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BL0PR12MB4948.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(346002)(366004)(396003)(39860400002)(136003)(66556008)(6506007)(54906003)(2616005)(66946007)(66476007)(52116002)(956004)(38100700002)(6512007)(450100002)(4326008)(8676002)(8936002)(478600001)(2906002)(6486002)(86362001)(26005)(186003)(16526019)(83380400001)(5660300002)(1076003)(36756003)(6666004)(316002)(38350700002)(69590400013); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 2bVBZ3jrwJXOmfMZvT3qywnVIJxLElDtSwyjViLhznlSfbP01DNdVLM85DrhgQBRoB0WZYVY2WTzNKLO+HXblpQ099WcRzO69HwE1eCRyHeShwS1l8lfEkm0ikm0M3LLONULkV2GJSkCvjgoMUvxmV+q+iw3TSUDQTBfIbqyODiKkGhhy5xL60u3xDIfTwvNq65Aef+hZeL74URR2Clr3mKGYD2R4B0uiWjzYUHhEi3yK2i6QNHAq4MY8EaM3O3QFM6r/E9oawOGRolBTgBqknwaCQDmLhCB5rCySVbvW0z3+O8PNgSmQaeyJyU/ZmtOGtGq+eqcQfZOA9LV0ZFCJyx97wNoWnalGQnHjB5Tji4KoektA/YVZmSNrNsMv0JBzsbsy1MhTrLeg2u77FTrwoO+vESSKLFy0D85Fp4Lvw4calH6x258z5MMy223vbO7tTDdxSgCMC7zbOHmLzMsF7YqwhvWU5IJQS+dBYCq4ktZCQcLVCG/bsmZf8uJVPq/hol6v2E23ojRyBF665pm2iv+noQW7Vl2mB5Nqa4iVW/wQ3JenFkHtOhNQdjAztr6pdcfdqIEn6witlMR3nzfoxt8PRLcxsh+bnwCVVw3/HQqzr2UatXzPMBmUTcqyBtgUPUqkgsnKrb5IOBbnsBKAIaw1pvETAQgAO7/Tw2PRYsrfnhnueaNSFpAYZ4gMpkmiVwFiYiVjD+tshvkVOYdIAFtRX8yoErwaAE1lQ7+BbyA3w6qHCua+/NNZLo9GElpgXRf3uz0mVPAdvvEYB41C7nI6fFJBBMPRdqOkb68hr7Ibm4hG9k3A7ypBo93p5kNkw0IR2YOA/8K0Y8J4GV9qzp3oWl/PxvjjMwvmLK0UFY/JWChbEoI4Y64YNUtKlp4u0IeTQuwjrP29ToDbbX85ncUZm41hXUP0oHg3wf4CPYYRHClPzXde0d2ZxIyvLHiVSMjFGymUliFiWk0YRNXbwUkaPxjbo7omwZBnwdidDi8Pml8yNhZ1tD5WmiVKQwmXHeCgJDGDN4kI20QUXMmHw6M8zFCqfAII3dUhZ2hwOcwbMs+H2v2rpAvs7eFXFbskE2MytDT85SMebMIseocMcm61Ene/jXVM3mCzXbl6BWHYpCgnSEGVdPbMYxzpI0A+YXL78I7ClvGt2jfMV1/tnCJ0iFFCkS/y4OKFLRDth8AHBOxlyrO0kDAmKiM9aUsDdGvlXpC7VagEVt7K897FeeoXIFB4xdTcURzV1OO/N8NPEA5DqF0q+EAX5e8GVIdycYYq5qUDazzNCCkC+I6mUid9H2KLyQ49nE1NgV4UNGsE5Altb6HKODuFHvIdtOR X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 273b963b-dac6-433a-0ac8-08d90c4498f4 X-MS-Exchange-CrossTenant-AuthSource: BL0PR12MB4948.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 May 2021 01:58:21.5953 (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: 8vI8bDgf4nRB6r/7Oxr4LLzX/hmBDfQIULh0GLH5dTz01ySPvVtfM3469CdCWpHT4xave7aptph5mrhU5k0unA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4142 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: David Yat Sin , Rajneesh Bhardwaj Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Rajneesh Bhardwaj This IOCTL is expected to be called as a precursor to the actual Checkpoint operation. This does the basic discovery into the target process seized by CRIU and relays the information to the userspace that utilizes it to start the Checkpoint operation via another dedicated IOCTL. The helper IOCTL determines the number of GPUs, buffer objects that are associated with the target process, its process id in caller's namespace since /proc/pid/mem interface maybe used to drain the contenets of the discovered buffer objects in userspace and getpid returns the pid of CRIU dumper process. Also the pid of a process inside a container might be different than its global pid so return the ns pid. Signed-off-by: Rajneesh Bhardwaj (cherry picked from commit b2fa92d0a8f1de51013cd6742b4996b38c285ffc) (cherry picked from commit 8b44c466ce53162603cd8ae49624462902541a47) Signed-off-by: David Yat Sin Change-Id: I2c6b28fe4df7333c9faf7eb6ee86decabe475338 --- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 42 ++++++++++++++++++++++-- drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 2 ++ drivers/gpu/drm/amd/amdkfd/kfd_process.c | 14 ++++++++ 3 files changed, 56 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c index 1fa2ba34a429..6b347ce5992f 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c @@ -1822,9 +1822,47 @@ static int kfd_ioctl_criu_restorer(struct file *filep, static int kfd_ioctl_criu_helper(struct file *filep, struct kfd_process *p, void *data) { - pr_info("Inside %s\n",__func__); + struct kfd_ioctl_criu_helper_args *args = data; + struct kgd_mem *kgd_mem; + u64 num_of_bos = 0; + int id, i = 0; + void *mem; + int ret = 0; - return 0; + pr_debug("Inside %s\n", __func__); + mutex_lock(&p->mutex); + + if (!kfd_has_process_device_data(p)) { + pr_err("No pdd for given process\n"); + ret = -ENODEV; + goto err_unlock; + } + + /* Run over all PDDs of the process */ + for (i = 0; i < p->n_pdds; i++) { + struct kfd_process_device *pdd = p->pdds[i]; + + idr_for_each_entry(&pdd->alloc_idr, mem, id) { + if (!mem) { + ret = -ENOMEM; + goto err_unlock; + } + + kgd_mem = (struct kgd_mem *)mem; + if ((uint64_t)kgd_mem->va > pdd->gpuvm_base) + num_of_bos++; + } + } + + args->task_pid = task_pid_nr_ns(p->lead_thread, + task_active_pid_ns(p->lead_thread)); + args->num_of_devices = p->n_pdds; + args->num_of_bos = num_of_bos; + dev_dbg(kfd_device, "Num of bos = %llu\n", num_of_bos); + +err_unlock: + mutex_unlock(&p->mutex); + return ret; } static int kfd_ioctl_criu_resume(struct file *filep, diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h index a494d61543af..74d3eb383099 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h +++ b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h @@ -932,6 +932,8 @@ void *kfd_process_device_translate_handle(struct kfd_process_device *p, void kfd_process_device_remove_obj_handle(struct kfd_process_device *pdd, int handle); +bool kfd_has_process_device_data(struct kfd_process *p); + /* PASIDs */ int kfd_pasid_init(void); void kfd_pasid_exit(void); diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process.c b/drivers/gpu/drm/amd/amdkfd/kfd_process.c index 9d4f527bda7c..bc133c3789d8 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_process.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_process.c @@ -1359,6 +1359,20 @@ static int init_doorbell_bitmap(struct qcm_process_device *qpd, return 0; } +bool kfd_has_process_device_data(struct kfd_process *p) +{ + int i; + + for (i = 0; i < p->n_pdds; i++) { + struct kfd_process_device *pdd = p->pdds[i]; + + if (pdd) + return true; + } + + return false; +} + struct kfd_process_device *kfd_get_process_device_data(struct kfd_dev *dev, struct kfd_process *p) { From patchwork Sat May 1 01:57:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Kuehling X-Patchwork-Id: 12234569 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=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 6A603C43461 for ; Sat, 1 May 2021 01:58:37 +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 24BE1613F7 for ; Sat, 1 May 2021 01:58:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 24BE1613F7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none 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 09D3F6F62D; Sat, 1 May 2021 01:58:26 +0000 (UTC) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2084.outbound.protection.outlook.com [40.107.92.84]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6458A6F62A; Sat, 1 May 2021 01:58:24 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GexgMiODj4rDiy/hE7yFBi230FzSguLP0+Ny6zhrdPajxfabC1uRUju/Ylqz12nnnC1FuElsgTHNqhwLXOBmQhsZQrH6UbttUb4BlQjj2uyRyZ9kkOgKLz3O7YalZ4IHrv9Hasfs5rOfivJ5tVh+ZXFppS7u8jNnL8h4F4gON6bQYrut9IXyrXvB+fYiaOyHp49RhQu7MFhH0XD/1f0HvlfSsMGBLbVHbzW1ejnRif/MgIKBL4U8qTuf0xvRPLunSHg5ZDC7ENG3u5L4if5mVjX9Nx8XDFQweMmsv60djZKSu0nrqQU4gU0gKJL/AH7d8VPW5Zqy3trmzil34KgnrA== 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=AGbL5Z1uEJL6qKbL9W3FhW+k+4tH61MLCE34y69t2Bo=; b=AJniU+jgl1oz8Jr6ivfJWfR4rn2oQtKIW7bzdjo/JkhY0WZNhYVWFG220A+OPQ5fR4OhPHQmNQK/leOg8YKhpT/Urk9scd7aH/sUl4T+UciiBLNf0284O+mrwepbWXoACDQnNV1rRc4Nl3aFoURx+iIaM+flEJOUqyBbIlLiHe6DbNPM4cwm0mVn/UJSOOkM/wLChgoqYKA1+tS0VsMn8+ZVcSvVvctw5E4YvBOY2O/+AG+DIZrWgDc/eubRAVAIj+u9zDgLI7eea+Ox0wJb64hPq2UV9yTyHmFBXiadEz7MZ419NE1aI7/az6sc3XHFedu0oQFk8j09UYqhpBH6qw== 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=AGbL5Z1uEJL6qKbL9W3FhW+k+4tH61MLCE34y69t2Bo=; b=x7hf8r1IOAFJ9ZVn9UFPKC3cGzv+VBNFc9E18E7pZASM+TGPTqo6f5Q04qk3PL3TgBTxwx3523uj2YsqEkFFEANQ1yuXS/HM5m4Vk9q6bBSzedUNtVzL8JitXLzeS52BvjoRHBFYmDViTnIO8JbRKe2cfVmRZDyQGYZH4VuQQyw= 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 BL0PR12MB4948.namprd12.prod.outlook.com (52.135.46.212) by MN2PR12MB4142.namprd12.prod.outlook.com (52.135.51.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.25; Sat, 1 May 2021 01:58:22 +0000 Received: from BL0PR12MB4948.namprd12.prod.outlook.com ([fe80::70f5:99ed:65a1:c033]) by BL0PR12MB4948.namprd12.prod.outlook.com ([fe80::70f5:99ed:65a1:c033%5]) with mapi id 15.20.4065.027; Sat, 1 May 2021 01:58:22 +0000 From: Felix Kuehling To: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [RFC PATCH 05/17] drm/amdkfd: CRIU Implement KFD dumper ioctl Date: Fri, 30 Apr 2021 21:57:40 -0400 Message-Id: <20210501015752.888-6-Felix.Kuehling@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210501015752.888-1-Felix.Kuehling@amd.com> References: <20210501015752.888-1-Felix.Kuehling@amd.com> X-Originating-IP: [165.204.54.211] X-ClientProxiedBy: YT1PR01CA0037.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:2e::6) To BL0PR12MB4948.namprd12.prod.outlook.com (2603:10b6:208:1cc::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (165.204.54.211) by YT1PR01CA0037.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:2e::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.25 via Frontend Transport; Sat, 1 May 2021 01:58:21 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 633a62bf-04ff-42aa-9eca-08d90c44999b X-MS-TrafficTypeDiagnostic: MN2PR12MB4142: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:404; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nyhVKw77Slpvb75GM0gEpHAlIfMX4O9D6PQ9pBG6LUF17N1ST9E5ghEfBvWDk29Ztds88Z4RlbBFS5g5NONpG1yx7YHR8kDZzIMjV4dRul3XL6XMxjpNU4dikRRblKcXJkSjAuqRNVCWOSGYYReKsqrx9pXXeWlgSKlsVfAcG2EcowZv/2yaVfbTClWV0EOqU2fUr6XC1LNoO7DZ5f5nwCbY2dr18N7eRkb/kO4JtVebpJb8OnI8BGUYg0mupDfmQVLCE/FkNdIX+tMjnTf8U0ZwNsrRb8S13Q02pAAWhTPfD+WEfuiaBlPQvsef0+iWDSdcMU89WUx/rTfbL16Aun+OUW7jqd3tPOpGRMJosE29CcYoMk1J7L1Ce1SY+UY/kgNYpQFg2xT2UA/4AyAykXPK9iGmggs1QclevFnfJRtnHZyZSxu7J89VTfQWYNHR8tMEnAiKi9PTCc9KQ32/gPuUi2j1DzpIRQtq+duLanYg4oekMdmKWYfk1nVKR6P6GsjPKDWdjMNfQYQ7sQPuIFULvGdVjp6zKNMTBb4tNTYAIC5l/fmaMGweyemqf4/clDEwyWjfZoOhrhtRdMOFb8gtOg3ZDNIuwM/83TPCAY25g9vsDDvSTZzZRUqQbDOoYeRZLOQNRgMJid3kYzeLMl1ylfUVaspXak8GZ0ez9D19ggGruOq1eui4TY1JNbHf X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BL0PR12MB4948.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(346002)(366004)(396003)(39860400002)(136003)(66556008)(6506007)(54906003)(2616005)(66946007)(66476007)(52116002)(956004)(38100700002)(6512007)(450100002)(4326008)(8676002)(8936002)(478600001)(2906002)(6486002)(86362001)(26005)(186003)(16526019)(83380400001)(5660300002)(1076003)(36756003)(6666004)(316002)(38350700002)(69590400013); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: PEq+30bMywq7nBnKfhnjcCuEDUVpFIIZ5B8p8m/4dvXoH9p+6vZrLyHVFm4XysxgGESEMTZp69PfN+G/v/I86N7tbE9OPWdOpuMGdLMTRCNGGu0BFJTCTNV8RW9VO+D1UZ+el3IJmVujryg3y2ReGQmMEOEl/2m54zupnUEtKjZabisN3FO5+2upfpgLDY6L8IQNJkjSwhGd8v60Vo2oOoSefY/gs4rQ+L2aJenK96Jh45+sf7rSyD1MNoQuJGpDiiQ2ekaaSHVovnF9gOB/yqiQdsIAGatIknzWzM/jr6CRq5za+WTz3fvGhgZriSTCMbAxOsfDeHOLLZTLFgRzqJTs0hjCT986xwkjJKx7PikwY/negToPu8V6DU15JPCYBtTkkKcoucLlDqi9KGBQFLlc7ybIYmrY2d4EDRi7sIZ/+iOPfjcPjl9v2V0jBtHLGd2Jbz/znWzsDIAV01bvF0OWfj6lFiFzkELFQ72JjBkb6X6pa/DY35dIel2fR42CVlDe5sZ1dL8Wm8aaeJBfLXVgTapf8H6V0sJUxeuaaeX4+wXNWZhseGgN1U5cgpUsR7z3XBFjeVureEtfITiXFTzzvUEwZTB/AFgvBdDol6M51hd9d/jLoZ3xvR5mfsHLoaVVLPfqSEFGFuMp1e7vAIQyYwnO5nFNYPggn1IjLNLb4nuwyP14mejH9TH1sNrtfqMhGTwSbTVB+1sPyW8+wEwMzKJJ8M82qbHQiT5qFZ5AcqILG0LQPf1Y12DJcePZG8o2Fev6GQjTBvQGfO72TmKV5SzzF/Xm2BZRpulUte6tV+yz3kVSnlbkcQDBDWSM7mxK2vX1NXULavb4zo2k4ONGJYRvZWiEk2X4LGgU0iJTt6cD8zxmO2v/pPTGhow+xKJMlPcRQYFUbjp4slFyJ0ZvLoKACQIFyKNz971bAmiUOjazJn/8G6bnbgQVDCw7ZkHuGDiSttjzTTgmcUmWldZpEg5EvvH3tpdDLOxV/sxFtN7JrMRvuUeY3uYePSaXpKswMpgRmnXwJ4innIC3JRaYIUnWGVjlz3ui5SL9HuuqfB8u0q1sx9xE0WBBdrD4r1WKeDIbyL36lw/FV9Ulo+feElnqDMoci3HTnBsL6C4aeeByYugUU4IkzSVklJ4+I8JacnyyiTzlNK0ZbqVD2ObP0im4ZwDUfNT0Nnp7TYC9Zwb9UyEgz15vN+crTVBniktWxF7T9O4QfzcmH6ak3z9KJDhlAykQnk+qKBLO1DYoVQiM0AqUq/kgte1LOfRSGOWustVvxYYbttjkf0fR9gmW/zkG1wkZc0vNVyxqIVeY6KmPsMhzn3vx21g2wzhz X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 633a62bf-04ff-42aa-9eca-08d90c44999b X-MS-Exchange-CrossTenant-AuthSource: BL0PR12MB4948.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 May 2021 01:58:22.5840 (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: 9QY0N/vBQiB9NM3ejrpSSSe0Z3CA2CHKqewQQJS+dmF5XAL/H8UvMHnMLMNMQx7wW8zeV6rlF8r3o5SygsOSOQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4142 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: David Yat Sin , Rajneesh Bhardwaj Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Rajneesh Bhardwaj This adds support to discover the buffer objects that belong to a process being checkpointed. The data corresponding to these buffer objects is returned to user space plugin running under criu master context which then stores this info to recreate these buffer objects during a restore operation. Signed-off-by: David Yat Sin Signed-off-by: Rajneesh Bhardwaj (cherry picked from commit 1f114a541bd21873de905db64bb9efa673274d4b) (cherry picked from commit 20c435fad57d3201e5402e38ae778f1f0f84a09d) Change-Id: Ifdbeee3606578db61bdc9aca7528272e20a38256 --- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 96 +++++++++++++++++++++++- 1 file changed, 95 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c index 6b347ce5992f..1454f5613e60 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c @@ -42,6 +42,7 @@ #include "kfd_svm.h" #include "amdgpu_amdkfd.h" #include "kfd_smi_events.h" +#include "amdgpu_object.h" static long kfd_ioctl(struct file *, unsigned int, unsigned long); static int kfd_open(struct inode *, struct file *); @@ -1806,9 +1807,102 @@ static int kfd_ioctl_svm(struct file *filep, struct kfd_process *p, void *data) static int kfd_ioctl_criu_dumper(struct file *filep, struct kfd_process *p, void *data) { + struct kfd_ioctl_criu_dumper_args *args = data; + struct kfd_criu_bo_buckets *bo_bucket; + struct amdgpu_bo *dumper_bo; + int ret, id, index, i = 0; + struct kgd_mem *kgd_mem; + void *mem; + pr_info("Inside %s\n",__func__); - return 0; + if (args->num_of_bos == 0) { + pr_err("No BOs to be dumped\n"); + return -EINVAL; + } + + if (p->n_pdds != args->num_of_devices) { + pr_err("Invalid number of devices %d (expected = %d)\n", + args->num_of_devices, p->n_pdds); + return -EINVAL; + } + + pr_debug("num of bos = %llu\n", args->num_of_bos); + + bo_bucket = kvzalloc((sizeof(struct kfd_criu_bo_buckets) * + args->num_of_bos), GFP_KERNEL); + if (!bo_bucket) + return -ENOMEM; + + mutex_lock(&p->mutex); + + if (!kfd_has_process_device_data(p)) { + pr_err("No pdd for given process\n"); + ret = -ENODEV; + goto err_unlock; + } + + /* Run over all PDDs of the process */ + for (index = 0; index < p->n_pdds; index++) { + struct kfd_process_device *pdd = p->pdds[index]; + + idr_for_each_entry(&pdd->alloc_idr, mem, id) { + if (!mem) { + ret = -ENOMEM; + goto err_unlock; + } + + kgd_mem = (struct kgd_mem *)mem; + dumper_bo = kgd_mem->bo; + + if ((uint64_t)kgd_mem->va > pdd->gpuvm_base) { + if (i >= args->num_of_bos) { + pr_err("Num of BOs changed since last helper ioctl call\n"); + ret = -EINVAL; + goto err_unlock; + } + + bo_bucket[i].bo_addr = (uint64_t)kgd_mem->va; + bo_bucket[i].bo_size = amdgpu_bo_size(dumper_bo); + bo_bucket[i].gpu_id = pdd->dev->id; + bo_bucket[i].bo_alloc_flags = (uint32_t)kgd_mem->alloc_flags; + bo_bucket[i].idr_handle = id; + + if (bo_bucket[i].bo_alloc_flags & KFD_IOC_ALLOC_MEM_FLAGS_DOORBELL) + bo_bucket[i].bo_offset = KFD_MMAP_TYPE_DOORBELL | + KFD_MMAP_GPU_ID(pdd->dev->id); + else if (bo_bucket[i].bo_alloc_flags & + KFD_IOC_ALLOC_MEM_FLAGS_MMIO_REMAP) + bo_bucket[i].bo_offset = KFD_MMAP_TYPE_MMIO | + KFD_MMAP_GPU_ID(pdd->dev->id); + else + bo_bucket[i].bo_offset = amdgpu_bo_mmap_offset(dumper_bo); + + pr_debug("bo_size = 0x%llx, bo_addr = 0x%llx bo_offset = 0x%llx\n" + "gpu_id = 0x%x alloc_flags = 0x%x idr_handle = 0x%x", + bo_bucket[i].bo_size, + bo_bucket[i].bo_addr, + bo_bucket[i].bo_offset, + bo_bucket[i].gpu_id, + bo_bucket[i].bo_alloc_flags, + bo_bucket[i].idr_handle); + i++; + } + } + } + + ret = copy_to_user((void __user *)args->kfd_criu_bo_buckets_ptr, + bo_bucket, + (args->num_of_bos * + sizeof(struct kfd_criu_bo_buckets))); + kvfree(bo_bucket); + mutex_unlock(&p->mutex); + return ret ? -EFAULT : 0; + +err_unlock: + mutex_unlock(&p->mutex); + pr_err("Dumper ioctl failed err:%d\n", ret); + return ret; } static int kfd_ioctl_criu_restorer(struct file *filep, From patchwork Sat May 1 01:57:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Kuehling X-Patchwork-Id: 12234571 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=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 4E68BC43460 for ; Sat, 1 May 2021 01:58:39 +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 173D4613F7 for ; Sat, 1 May 2021 01:58:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 173D4613F7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none 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 B490A6F62B; Sat, 1 May 2021 01:58:26 +0000 (UTC) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2084.outbound.protection.outlook.com [40.107.92.84]) by gabe.freedesktop.org (Postfix) with ESMTPS id 906886F62D; Sat, 1 May 2021 01:58:24 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iGjsNpKqSFfN1S9n+DK0BqNOSLpQrOqDB4TEjCvOH24HSgYS1VNfyGbjx/erpIqFRziXxyRueJiSVL4PmJkP8rYS9A1glXkgXorU1OCgRPUrrAeSpzcbF8prDtSjOSKr6pzky8gIf43och5gkPE9mXmDC1h3yjdsnXEG/Cl9B4X7UuJDRCe9335P+go8UsBQVsSwVeNW5tRF/libEhdqG5F5S6PUKZlvFxvD80sisZXci8IbkWw1QfD4wK303AnBz8bECr0TMbpqKFJvZ/yc+opZ7CLnk/frBGWgxL0D4hV1vVFX+5SYxiIJNCe0+8Yruy6CIaJURBPvPA0UBioCCw== 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=iwNqNO7MWzIZf9LFjo8c7I5WO9TTBTmlm5CBu+JA5uk=; b=JZ1Nk6qF+1Zl/EuIRR7dH/y7W8A5JakfVdhk77uudm1/S3JHuyOg6kbzprqFwOa1Bb0xOUO33FUIkpxXSkuDzxTY1WMuSvCI033q4XzkL3GhoZoury+FZ6p5gJMLPH6TS2xwIHU+xEtldd/Tst/PiOzjAY1KrDjLYoJ+bC3mPyAojyoUfXpR7pXgUFpflASCDrwX/Aj2S4h04fXAFFwBmaMZpwOUxK1InUUhxvcrnoVYJNcsjQworGag3GOu5Gwb46TrJ0gbfIQoXskgkdSINZqzQsLzfubHhcWWLDid3J9nlquOFIjhrDvK9hWjPMypAkCfSa9ujxufKRDEZNqv0g== 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=iwNqNO7MWzIZf9LFjo8c7I5WO9TTBTmlm5CBu+JA5uk=; b=2WNOK+RacK77sCZMj+Ckw9dYrswzi1Q55jES7uHHr6Cxr0k0T4qhZbXTUzCQM3Xsr7/GqOWC+9IQXJfVYf/UVl9FfzDPOAJ+mAumqLzZ6GYYtwzo+DFlDxLJIDeG4uFgRY0KwyE6NAAMROJbsYajbdN9Ux0f2ehcd65XNK4qLSY= 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 BL0PR12MB4948.namprd12.prod.outlook.com (52.135.46.212) by MN2PR12MB4142.namprd12.prod.outlook.com (52.135.51.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.25; Sat, 1 May 2021 01:58:23 +0000 Received: from BL0PR12MB4948.namprd12.prod.outlook.com ([fe80::70f5:99ed:65a1:c033]) by BL0PR12MB4948.namprd12.prod.outlook.com ([fe80::70f5:99ed:65a1:c033%5]) with mapi id 15.20.4065.027; Sat, 1 May 2021 01:58:23 +0000 From: Felix Kuehling To: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [RFC PATCH 06/17] drm/amdkfd: CRIU Implement KFD restore ioctl Date: Fri, 30 Apr 2021 21:57:41 -0400 Message-Id: <20210501015752.888-7-Felix.Kuehling@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210501015752.888-1-Felix.Kuehling@amd.com> References: <20210501015752.888-1-Felix.Kuehling@amd.com> X-Originating-IP: [165.204.54.211] X-ClientProxiedBy: YT1PR01CA0037.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:2e::6) To BL0PR12MB4948.namprd12.prod.outlook.com (2603:10b6:208:1cc::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (165.204.54.211) by YT1PR01CA0037.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:2e::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.25 via Frontend Transport; Sat, 1 May 2021 01:58:22 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f1c6314d-d19a-4658-00b7-08d90c449a28 X-MS-TrafficTypeDiagnostic: MN2PR12MB4142: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:226; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /n93Z9pWzEihitbT2/jRrLTYJw3ue61SaVbDtiDdwaz4OKWNDdtPsLj0wcXtzGzUX/9UfIPvFW/pWYSXdjss+Od8hCTelEYsMSK1YXU5YfbK+vMGqtFXMVCASIYb1d8fjoXONW3oKAXmaSBidp6CJNmgWBntHUR8yzvyTSSVtBtOey5R/IeK7bOS7vkQuEXo5nRZsJFd9Oh4LzxBIpiBr2ndvKNTp5Zq2dS0J7wgImuOJjP9E4JDCh7mA1gJOYXqndKe7VJ2MUOpcBTdWBiGnTAjgSe8gEizz6Q8ZOYRyiqCXwRUgDf6pENyCryRXYx223/q7+5vjIyiYtyi+e2m+PEi/Kh6v7Y1lXnKw3p11eGBMtYlglT/BXLhoqGp5HHCUxJBmTUU6gzL2lPXyptqMLIP6M8SSH70UUbZHH3Fs3bbK2WmelZjN3DH42JHA178AerTueTShJS2oYffMvPdCZQ6PflJ7p2uOL6SW8zjU2Za2HRTTBvDdP38ifb62RuQDiBo2HMMAwcc2jSwaPL069iHIoCggLA3dO20rsbWpYI4BpyPTr271dX/pFevubghUjOeVgqnVzKCn8jhmHPSFLezD2I40jscEbAGktr1wn+DEN7BmgHm5jf9loMUA5dmO8ImpwnK4EaGQT9FW6piBFri8cJu8wBRv/fx3SckVfUJTQSsW0GyDB1TZpxkhngY X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BL0PR12MB4948.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(346002)(366004)(396003)(39860400002)(136003)(66556008)(6506007)(54906003)(2616005)(66946007)(66476007)(52116002)(956004)(38100700002)(6512007)(450100002)(4326008)(8676002)(8936002)(30864003)(478600001)(2906002)(6486002)(86362001)(26005)(186003)(16526019)(83380400001)(5660300002)(1076003)(36756003)(6666004)(316002)(38350700002)(69590400013); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: tDV+Tc9GbFpxXPDwjQWaTGMYv4lOzC41eArmQXPhOZbx6n4yICFPTKUe0pP5/gSjBTdiFrTdpA9RkllblssJQBpBSw9xHl0DXwqKerygW7DLM2sIIy9WEaTq+xbCmc0Ttls6MTRRodhf6bYyczJz0SUwxCdiyGqZb22bAgBikZluC2MJX/XJT7EiSpl60+umI3vZm8Sm6z6KHIsZYbBUzU8cgwcKBrCEZGVvEZazVe1EymeRjGJ4p26ZMmiwTkvMIKAcRzBCKyTM10G1toFcSXRz3sO8r1XPMUGM2/aknk4D7aiF1bxYPxrTw+NhU7/+cgZDp+p+mjz5MgVuEgNlOlaW9SVGeo3fDFKqxRywKANfwQdvXmgMpR1YR9M4Xoc8c2CqJxCELtUFqHRyuKq7c8TVQSlx1yazOnvwixu5Hkq01T39A/dWhugNvM6IgCYAlWFHTCypl2ZaLgkCz3Y2ybo3sXbATvjqRfFu44KD8Vp+hA/DzOZhMsZspID8gAwVdu/ME4OfElFbdkmpJTOLuDq/hRitcf1lh6jxpCLnX3Xo2teoj6BOS2TUZH7B2vLjd9t3Icp5P2nfiyEF0ab57qNUo6Vz+0LiU+QNm1rmuOz0gsEEalQU/QPDZzYLfOuZqO6QQlhBJC03dTy8lvA/ofSGynW1vc9ZpsOQH2K7iEKVGr+gqVP+s8w0CE8RuOEikAq929op2MKyz6bF3t8ltU/DbJJPg1hgODj34goNa5sqbv0WANrfhfYznKpX7M6OY8BJ7umCLavQ6oLdWsyjUBpPmJXqaLkwRt6sO7bVYZJNUjcO5Nuy0HiO3PkR3rtwuc+HK507XnWId5WaGjYEmoxqf/nJ+KfyslvZN1U7rC1XMTRSO6doYcxQCK7euBNMqWJq+vFL5NwKZDAsT3/+ijePtIxjzjq0HbmByxZGEZgH3D/DWp30pwONXkI4VwqY6aWWw31kzA5d6eTR3Qb3X3HT0uliJPAMQ+wlrdy397mnD0HaJRbhnO8zT6lVOf8KsG3S2fawM049v/A1zVSmIrJj1UPlLZLnnDvmGg+DRBaZ04Nx0mHHY8tOthLk9L3xu6MiGCZKAHJ5+YHPBwGJzsvUwhfKlg2udxG+BpFybWa+FNHmt/lgdRPC1NxD5shmBFWWUME6wV+PhQDR6Yfz1LZ3ZZNVOjuV3ZuDY4kSRK9Galt2tUYHNaGRzl8eo4Mdo99UQjyaZD6mCzitjUHmJGR2PJ+ZxSsbgCpkGe8OTjd/jnRGlVEjWlW/5LoaOOf0OdG3n1ukK5tiEHIPxgTxVQrueVDWq2V8HvyUIFw6SvaMUoRYcewFc8+eytIr1Fdb X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: f1c6314d-d19a-4658-00b7-08d90c449a28 X-MS-Exchange-CrossTenant-AuthSource: BL0PR12MB4948.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 May 2021 01:58:23.5757 (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: T5a8xv1aGlk98aTXX4WuXX+yinF8biw3MmMpy3PUWEc1cgPEJdiBnL2BbdDCwJPsGM0k5TTXmwXyU4L+2LZJOA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4142 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: David Yat Sin , Rajneesh Bhardwaj Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Rajneesh Bhardwaj This implements the KFD CRIU Restore ioctl that lays the basic foundation for the CRIU restore operation. It provides support to create the buffer objects corresponding to Non-Paged system memory mapped for GPU and/or CPU access and lays basic foundation for the userptrs buffer objects which will be added in a seperate patch. This ioctl creates various types of buffer objects such as VRAM, MMIO, Doorbell, GTT based on the date sent from the userspace plugin. The data mostly contains the previously checkpointed KFD images from some KFD processs. While restoring a criu process, attach old IDR values to newly created BOs. This also adds the minimal gpu mapping support for a single gpu checkpoint restore use case. Signed-off-by: David Yat Sin Signed-off-by: Rajneesh Bhardwaj (cherry picked from commit 47bb685701c336d1fde7e91be93d9cabe89a4c1b) (cherry picked from commit b71ba8158a7ddf9e4fd8d872be4e40ddd9a29b4f) Change-Id: Id392516c6af409f1e92303d8dc21411764f2d8fa --- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 321 ++++++++++++++++++++++- drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 6 + 2 files changed, 325 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c index 1454f5613e60..95d81d00daa9 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c @@ -1804,6 +1804,94 @@ static int kfd_ioctl_svm(struct file *filep, struct kfd_process *p, void *data) return -EPERM; } #endif +static int kfd_devinfo_dump(struct kfd_process *p, struct kfd_ioctl_criu_dumper_args *args) +{ + int ret = 0; + int index; + struct kfd_criu_devinfo_bucket *devinfos; + + if (p->n_pdds != args->num_of_devices) + return -EINVAL; + + devinfos = kvzalloc((sizeof(struct kfd_criu_devinfo_bucket) * + args->num_of_devices), GFP_KERNEL); + if (!devinfos) + return -ENOMEM; + + for (index = 0; index < p->n_pdds; index++) { + struct kfd_process_device *pdd = p->pdds[index]; + + devinfos[index].user_gpu_id = pdd->user_gpu_id; + devinfos[index].actual_gpu_id = pdd->dev->id; + } + + ret = copy_to_user((void __user *)args->kfd_criu_devinfo_buckets_ptr, + devinfos, + (args->num_of_devices * + sizeof(struct kfd_criu_devinfo_bucket))); + if (ret) + ret = -EFAULT; + + kvfree(devinfos); + return ret; +} + +static int kfd_devinfo_restore(struct kfd_process *p, struct kfd_criu_devinfo_bucket *devinfos, + uint32_t num_of_devices) +{ + int i; + + if (p->n_pdds != num_of_devices) + return -EINVAL; + + for (i = 0; i < p->n_pdds; i++) { + struct kfd_dev *dev; + struct kfd_process_device *pdd; + struct file *drm_file; + + dev = kfd_device_by_id(devinfos[i].actual_gpu_id); + if (!dev) { + pr_err("Failed to find device with gpu_id = %x\n", + devinfos[i].actual_gpu_id); + return -EINVAL; + } + + pdd = kfd_get_process_device_data(dev, p); + if (!pdd) { + pr_err("Failed to get pdd for gpu_id = %x\n", devinfos[i].actual_gpu_id); + return -EINVAL; + } + pdd->user_gpu_id = devinfos[i].user_gpu_id; + + drm_file = fget(devinfos[i].drm_fd); + if (!drm_file) { + pr_err("Invalid render node file descriptor sent from plugin (%d)\n", + devinfos[i].drm_fd); + return -EINVAL; + } + + if (pdd->drm_file) + return -EINVAL; + + /* create the vm using render nodes for kfd pdd */ + if (kfd_process_device_init_vm(pdd, drm_file)) { + pr_err("could not init vm for given pdd\n"); + /* On success, the PDD keeps the drm_file reference */ + fput(drm_file); + return -EINVAL; + } + /* + * pdd now already has the vm bound to render node so below api won't create a new + * exclusive kfd mapping but use existing one with renderDXXX but is still needed + * for iommu v2 binding and runtime pm. + */ + pdd = kfd_bind_process_to_device(dev, p); + if (IS_ERR(pdd)) + return PTR_ERR(pdd); + } + return 0; +} + static int kfd_ioctl_criu_dumper(struct file *filep, struct kfd_process *p, void *data) { @@ -1842,6 +1930,10 @@ static int kfd_ioctl_criu_dumper(struct file *filep, goto err_unlock; } + ret = kfd_devinfo_dump(p, args); + if (ret) + goto err_unlock; + /* Run over all PDDs of the process */ for (index = 0; index < p->n_pdds; index++) { struct kfd_process_device *pdd = p->pdds[index]; @@ -1908,9 +2000,234 @@ static int kfd_ioctl_criu_dumper(struct file *filep, static int kfd_ioctl_criu_restorer(struct file *filep, struct kfd_process *p, void *data) { - pr_info("Inside %s\n",__func__); + struct kfd_ioctl_criu_restorer_args *args = data; + struct kfd_criu_devinfo_bucket *devinfos = NULL; + uint64_t *restored_bo_offsets_arr = NULL; + struct kfd_criu_bo_buckets *bo_bucket = NULL; + long err = 0; + int ret, i, j = 0; - return 0; + devinfos = kvzalloc((sizeof(struct kfd_criu_devinfo_bucket) * + args->num_of_devices), GFP_KERNEL); + if (!devinfos) { + err = -ENOMEM; + goto failed; + } + + err = copy_from_user(devinfos, + (void __user *)args->kfd_criu_devinfo_buckets_ptr, + sizeof(struct kfd_criu_devinfo_bucket) * + args->num_of_devices); + if (err != 0) { + err = -EFAULT; + goto failed; + } + + mutex_lock(&p->mutex); + err = kfd_devinfo_restore(p, devinfos, args->num_of_devices); + if (err) + goto err_unlock; + + + bo_bucket = kvzalloc((sizeof(struct kfd_criu_bo_buckets) * + args->num_of_bos), GFP_KERNEL); + if (!bo_bucket) { + err = -ENOMEM; + goto err_unlock; + } + + err = copy_from_user(bo_bucket, + (void __user *)args->kfd_criu_bo_buckets_ptr, + args->num_of_bos * sizeof(struct kfd_criu_bo_buckets)); + if (err != 0) { + err = -EFAULT; + goto err_unlock; + } + + restored_bo_offsets_arr = kvmalloc_array(args->num_of_bos, + sizeof(*restored_bo_offsets_arr), + GFP_KERNEL); + if (!restored_bo_offsets_arr) { + err = -ENOMEM; + goto err_unlock; + } + + /* Create and map new BOs */ + for (i = 0; i < args->num_of_bos; i++) { + struct kfd_dev *dev; + struct kfd_process_device *pdd; + void *mem; + u64 offset; + int idr_handle; + + dev = kfd_device_by_id(bo_bucket[i].gpu_id); + if (!dev) { + err = -EINVAL; + pr_err("Failed to get pdd\n"); + goto err_unlock; + } + pdd = kfd_get_process_device_data(dev, p); + if (!pdd) { + err = -EINVAL; + pr_err("Failed to get pdd\n"); + goto err_unlock; + } + + pr_debug("kfd restore ioctl - bo_bucket[%d]:\n", i); + pr_debug("bo_size = 0x%llx, bo_addr = 0x%llx bo_offset = 0x%llx\n" + "gpu_id = 0x%x alloc_flags = 0x%x\n" + "idr_handle = 0x%x\n", + bo_bucket[i].bo_size, + bo_bucket[i].bo_addr, + bo_bucket[i].bo_offset, + bo_bucket[i].gpu_id, + bo_bucket[i].bo_alloc_flags, + bo_bucket[i].idr_handle); + + if (bo_bucket[i].bo_alloc_flags & + KFD_IOC_ALLOC_MEM_FLAGS_DOORBELL) { + pr_debug("restore ioctl: KFD_IOC_ALLOC_MEM_FLAGS_DOORBELL\n"); + if (bo_bucket[i].bo_size != + kfd_doorbell_process_slice(dev)) { + err = -EINVAL; + goto err_unlock; + } + offset = kfd_get_process_doorbells(pdd); + } else if (bo_bucket[i].bo_alloc_flags & + KFD_IOC_ALLOC_MEM_FLAGS_MMIO_REMAP) { + /* MMIO BOs need remapped bus address */ + pr_info("restore ioctl :KFD_IOC_ALLOC_MEM_FLAGS_MMIO_REMAP\n"); + if (bo_bucket[i].bo_size != PAGE_SIZE) { + pr_err("Invalid page size\n"); + err = -EINVAL; + goto err_unlock; + } + offset = amdgpu_amdkfd_get_mmio_remap_phys_addr(dev->kgd); + if (!offset) { + pr_err("amdgpu_amdkfd_get_mmio_remap_phys_addr failed\n"); + err = -ENOMEM; + goto err_unlock; + } + } + + /* Create the BO */ + ret = amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu(dev->kgd, + bo_bucket[i].bo_addr, + bo_bucket[i].bo_size, + pdd->drm_priv, + (struct kgd_mem **) &mem, + &offset, + bo_bucket[i].bo_alloc_flags); + if (ret) { + pr_err("Could not create the BO\n"); + err = -ENOMEM; + goto err_unlock; + } + pr_debug("New BO created: bo_size = 0x%llx, bo_addr = 0x%llx bo_offset = 0x%llx\n", + bo_bucket[i].bo_size, bo_bucket[i].bo_addr, offset); + + /* Restore previuos IDR handle */ + pr_debug("Restoring old IDR handle for the BO"); + idr_handle = idr_alloc(&pdd->alloc_idr, mem, + bo_bucket[i].idr_handle, + bo_bucket[i].idr_handle + 1, GFP_KERNEL); + if (idr_handle < 0) { + pr_err("Could not allocate idr\n"); + amdgpu_amdkfd_gpuvm_free_memory_of_gpu(dev->kgd, + (struct kgd_mem *)mem, + pdd->drm_priv, NULL); + goto err_unlock; + } + + if (bo_bucket[i].bo_alloc_flags & KFD_IOC_ALLOC_MEM_FLAGS_DOORBELL) + restored_bo_offsets_arr[i] = KFD_MMAP_TYPE_DOORBELL | + KFD_MMAP_GPU_ID(pdd->dev->id); + if (bo_bucket[i].bo_alloc_flags & KFD_IOC_ALLOC_MEM_FLAGS_MMIO_REMAP) { + restored_bo_offsets_arr[i] = KFD_MMAP_TYPE_MMIO | + KFD_MMAP_GPU_ID(pdd->dev->id); + } else if (bo_bucket[i].bo_alloc_flags & KFD_IOC_ALLOC_MEM_FLAGS_GTT) { + restored_bo_offsets_arr[i] = offset; + pr_debug("updating offset for GTT\n"); + } else if (bo_bucket[i].bo_alloc_flags & KFD_IOC_ALLOC_MEM_FLAGS_VRAM) { + restored_bo_offsets_arr[i] = offset; + /* Update the VRAM usage count */ + WRITE_ONCE(pdd->vram_usage, + pdd->vram_usage + bo_bucket[i].bo_size); + pr_debug("updating offset for VRAM\n"); + } + + /* now map these BOs to GPU/s */ + for (j = 0; j < args->num_of_devices; j++) { + struct kfd_dev *peer; + struct kfd_process_device *peer_pdd; + + peer = kfd_device_by_id(devinfos[j].actual_gpu_id); + + pr_debug("Inside mapping loop with desired gpu_id = 0x%x\n", + devinfos[j].actual_gpu_id); + if (!peer) { + pr_debug("Getting device by id failed for 0x%x\n", + devinfos[j].actual_gpu_id); + err = -EINVAL; + goto err_unlock; + } + + peer_pdd = kfd_bind_process_to_device(peer, p); + if (IS_ERR(peer_pdd)) { + err = PTR_ERR(peer_pdd); + goto err_unlock; + } + pr_debug("map mem in restore ioctl -> 0x%llx\n", + ((struct kgd_mem *)mem)->va); + err = amdgpu_amdkfd_gpuvm_map_memory_to_gpu(peer->kgd, + (struct kgd_mem *)mem, peer_pdd->drm_priv); + if (err) { + pr_err("Failed to map to gpu %d/%d\n", + j, args->num_of_devices); + goto err_unlock; + } + } + + err = amdgpu_amdkfd_gpuvm_sync_memory(dev->kgd, + (struct kgd_mem *) mem, true); + if (err) { + pr_debug("Sync memory failed, wait interrupted by user signal\n"); + goto err_unlock; + } + + pr_info("map memory was successful for the BO\n"); + } /* done */ + + /* Flush TLBs after waiting for the page table updates to complete */ + for (j = 0; j < args->num_of_devices; j++) { + struct kfd_dev *peer; + struct kfd_process_device *peer_pdd; + + peer = kfd_device_by_id(devinfos[j].actual_gpu_id); + if (WARN_ON_ONCE(!peer)) + continue; + peer_pdd = kfd_get_process_device_data(peer, p); + if (WARN_ON_ONCE(!peer_pdd)) + continue; + kfd_flush_tlb(peer_pdd); + } + + ret = copy_to_user((void __user *)args->restored_bo_array_ptr, + restored_bo_offsets_arr, + (args->num_of_bos * sizeof(*restored_bo_offsets_arr))); + if (ret) { + err = -EFAULT; + goto err_unlock; + } + +err_unlock: + mutex_unlock(&p->mutex); +failed: + kvfree(bo_bucket); + kvfree(restored_bo_offsets_arr); + kvfree(devinfos); + + return err; } static int kfd_ioctl_criu_helper(struct file *filep, diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h index 74d3eb383099..9c675755369a 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h +++ b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h @@ -758,6 +758,12 @@ struct kfd_process_device { * number of CU's a device has along with number of other competing processes */ struct attribute attr_cu_occupancy; + /* + * If this process has been checkpointed before, then the user + * application will use the original gpu_id on the + * checkpointed node to refer to this device. + */ + uint32_t user_gpu_id; }; #define qpd_to_pdd(x) container_of(x, struct kfd_process_device, qpd) From patchwork Sat May 1 01:57:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Kuehling X-Patchwork-Id: 12234573 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=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 355F5C43461 for ; Sat, 1 May 2021 01:58:41 +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 00AE2613F7 for ; Sat, 1 May 2021 01:58:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 00AE2613F7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none 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 264906F631; Sat, 1 May 2021 01:58:27 +0000 (UTC) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2060.outbound.protection.outlook.com [40.107.92.60]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4BA3B6F62F; Sat, 1 May 2021 01:58:26 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LxDP3grehusa/NIft52dHEb6RRs0hNtnzAYJEzuli2MENZm4n8ZSJQIGqMxMVFA6D13VuuFcF39gCXqjBvo4t3ufJTT+vN664VtoljnXai3SGCA2B65kSmWKp6mMuUW1m5ByeOdUR0aJmd1Ea4M0tCtz4GzQlITWxbbR/EITx2lToD0supG1q96xRDCbwC+FRrbflXqaEbhJzgB6gISuiuTqGxw89K1JsZJMr5p1Ku4O1kNqsprzDzddJhji/upSW5Y/JvuydxF838WtHOkyEqzuctChIXBDneJbSOo7NVBOdczhzV83iJkws2T0CNaXQVEuKYFOzfn7GH5wrV7Qfg== 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=BApRosyC1mUCRR3JLigEFegra94STXK/i+Cr8fuWv+o=; b=aSS2bRdDCu3KAvjOg46WvhtQayzoUzIs+q8qWBGJaYFph33QfDawvybQMa2xmcDlRBaswddN933ikum0vQrRsxfDKvO+P+U0m6miQqxpND6WQZYKcwaQ4Cz1R9qmJhj//k+sBHl0sGvxhwGGmJOTPY2HWBTP4lGZ2+vY11xWxvyzTEL0U8dNXedXpyXLz2MY1pEaBOGrd5k2vniu6vMbEjYs+5HoSXxpYbGNYG87P33z/oQAWPMXYr9h2Ix74UWEsjl4LIzBs+1p5xUlPViojpvsvzq3CbPMtwTtnLK71bsTL5JZ/2umuSMlWmUe9iKSf7u4h17x+QvPIX2E7afdCw== 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=BApRosyC1mUCRR3JLigEFegra94STXK/i+Cr8fuWv+o=; b=QAVx5v06FUwR+KjQY9QhTF6khZVLkYxdDIsZDSua4SKBeFAqGmYKoI6chTNzlo9ZtIit39dR46yNsdjfB/h8kLwa1+0xb7TjonQV0cDzh1C4yTSMvSG8OwR+mQ9TMkt6/6CBUjRLgOUIek3+oNwe9kecw1MJzuyZ2OyGNmW2fdY= 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 BL0PR12MB4948.namprd12.prod.outlook.com (52.135.46.212) by MN2PR12MB4142.namprd12.prod.outlook.com (52.135.51.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.25; Sat, 1 May 2021 01:58:24 +0000 Received: from BL0PR12MB4948.namprd12.prod.outlook.com ([fe80::70f5:99ed:65a1:c033]) by BL0PR12MB4948.namprd12.prod.outlook.com ([fe80::70f5:99ed:65a1:c033%5]) with mapi id 15.20.4065.027; Sat, 1 May 2021 01:58:24 +0000 From: Felix Kuehling To: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [RFC PATCH 07/17] drm/amdkfd: CRIU Implement KFD resume ioctl Date: Fri, 30 Apr 2021 21:57:42 -0400 Message-Id: <20210501015752.888-8-Felix.Kuehling@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210501015752.888-1-Felix.Kuehling@amd.com> References: <20210501015752.888-1-Felix.Kuehling@amd.com> X-Originating-IP: [165.204.54.211] X-ClientProxiedBy: YT1PR01CA0037.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:2e::6) To BL0PR12MB4948.namprd12.prod.outlook.com (2603:10b6:208:1cc::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (165.204.54.211) by YT1PR01CA0037.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:2e::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.25 via Frontend Transport; Sat, 1 May 2021 01:58:23 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 54b4b91b-176a-4358-25ad-08d90c449ac1 X-MS-TrafficTypeDiagnostic: MN2PR12MB4142: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:172; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CArZK4gdF4KZ7bibLn4Bpx+NU+LkBNiGg898Qei28O+MxB7pXvYA1GLVBnbLO1A4FkyrNg4q0cCkGdoWAzk0ifkupDsA/U+HtyrKnb0PY1MuGpud7AGioCVz4662e6CORIfh3qElAdnIDBncfZbLgC8hDZsvbDgbccTTivFZoWKAEmNTido/VCxmLqpv7nFn3uHArqzj/2pHaqF509WuwBkc2FI++Mp7syrt2PLFz5Sr1u+3LUtW0BpuA7c0YaNf48+z83FoSfV1Duj7QBIlUxXzzXODFzmnCL1/BfSSeX6AEuEe+NhV6hTp0rPwsCLNvsMzww/1pwC7o7sbWyVMPWcaLXuVac0zHwS2eanaAYwEuBkDJteAZ9R4amUtIHQMP1zrVlF5YMGeLpI591J7byD67uDaMn/RVqGC16XXvsQ4LPAv8uDQyIjewuakYU+fuisud/kP/LuA5rON+R1MnQWf0FIYFJZ6FzVO+0LgZz4gUCV/gE1bJOXnWuRREUcMDVHOdSr5MEyMxE3jKuGlVyY0M6/rQQZUae/Rxy4Gf0DpdhBeUR9Q3b4IaXFkxTShFY2T6ty1CzQLqiMEKQQXLqhMe9O5DPSQq146XUYQ4U++K0Jt1+QtX0DPSPg9kmQwBY4PDzQtPgPoOH3eq+SOUxqBBB/O3e2RyaxMy97fx1LpXwrx7/I8Cg3L/aMd7DNR X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BL0PR12MB4948.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(346002)(366004)(396003)(39860400002)(136003)(66556008)(6506007)(54906003)(2616005)(66946007)(66476007)(52116002)(956004)(38100700002)(6512007)(450100002)(4326008)(8676002)(8936002)(30864003)(478600001)(2906002)(6486002)(86362001)(26005)(186003)(16526019)(83380400001)(5660300002)(1076003)(36756003)(6666004)(316002)(38350700002)(69590400013); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: xGIidgwbudcDHXpbcQrZd1BFBhcmfgxFB3qGT5119ykROGMlCBL5bAldK1LoBFKhVhB+/ScxPlraCeRxuFD9OhoxgzebpvZINHUIaqN5Cdkq2wOudmb3Ln49/UZUZJilqWzWiHtjfqfGBfCkcGdqY634qw3aXOhGnEmgy+Cmc7HY7l3mtJN1Wpsxt8+EjKct5eFGuh7b0RyEyUOLeHvdaQsBpH75uBnH2U4kgFzFb1Ohzxvw/b+10OthcwYMJyZTq+5bNxr4Ka8GLU3QXy4dMxxbDSI4Pgh5kj9HGTyh+8AhxoCU8uYtRhdJ9ILRYke/uP/WBvka8VXfNiZ+NhIOZzESVhUYI/TUogB60s0qLZN90KX5pvNO9J7CFgBGVMPe9Z4B8glZAky3QMg/7mX15NKGXfiDZ/GcrUSWtRFYsbMUZ7y+UC5472ie0FiH9Xbq0xiM1sQkCLUeQ/cn63BS8zXbTvQLIDwlctaVSAHJEeSUiZUXcxZIKK6AZDbdA5TxkztYS7ue4mjsFalaFw9tsfAUlFHNZYBFABj+nnMKu1paRZuSYpGUmBeaeVgtwXz50wuAGgQ01MrGmf8PvkNFvv+q/79h0/bDKzDnC+t4ZAjSh20DfscEZqQ0Tt37HIylZ0c0mrbao1WMouLs9YKdsd2+0jGJMpCM/KAczjEEZga30T22O7aw587dY0H+WHMLsg+5Qu8Zv8SiI97xmJMAXAwdwIaUGjpAzkVmwlCNWHM0MIieKPF3GHQENoktlBfmG2GUwW4F7tPVN71TQXWIrQKJbqX0dvvHBq583FwaLankyjMx52NDsV6axUdYL6vSb9wA5J48p72N59yyqn4M2V6bLdBn07sO6OKuMeCScUAwgwIfN2MS/cjcWovgqx0g42DsCQxcuGNXznGQeiiLyCKwDXjepg+3pD0zDiPqDtJmSkxsXqzACe7JmdHDDDdM38uIo8WUCOGm9gcNVmmf1k3jYHd5ujXjPsk/AidmRTrCZ0BMekHyA7cqiGuTdIOrmO798ctJjzKSWoUT557UOEfrdih5rDnN3Sa2TkQ7Dqu96t4ngQMNbAiJRUkF5d9d8ZhzUrG4tAaR9jSP6Fyp03PV2HVA4MzkmoDoPVxexL7jQfya8osQzSlDdM7ARTIi24+thtmqAEJMuGFuJb3/fjs10plIf2/53SjN89r9ob/K4xEQWu0YlZTGn99u3gEk5vFIzgWqUjsmSHbIiDMNa+9SX6Vgqn3FmLKstGykeaV1udTAwcBhna8V4+SG4BXlYlROSeQWdxAKHyZWi9BUpAGUc2qlG4P/GkmzJhypEI1DjF9TJwiXn7Az43puE6/H X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 54b4b91b-176a-4358-25ad-08d90c449ac1 X-MS-Exchange-CrossTenant-AuthSource: BL0PR12MB4948.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 May 2021 01:58:24.5415 (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: ZWuieOZmgwr6DToopK6y50YK+ZP1sHdnOI5HqPW7EaBK6cDjgBlbSUcOOCWDAuJLETYLV19V6yr1wG5dDgjlRA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4142 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: David Yat Sin , Rajneesh Bhardwaj Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Rajneesh Bhardwaj This adds support to create userptr BOs on restore and introduces a new ioctl to restart memory notifiers for the restored userptr BOs. When doing CRIU restore MMU notifications can happen anytime after we call amdgpu_mn_register. Prevent MMU notifications until we reach stage-4 of the restore process i.e. criu_resume ioctl is recieved, and the process is ready to be resumed. This ioctl is different from other KFD CRIU ioctls since its called by CRIU master restore process for all the target processes being resumed by CRIU. Signed-off-by: David Yat Sin Signed-off-by: Rajneesh Bhardwaj (cherry picked from commit 1f0300f5a4dc12b3c1140b0f0953300b4a6ac81f) (cherry picked from commit 5c5ae6026ea795ae39acff06db862a7ef2fc6aa9) Change-Id: I714bbd8bec35feb47e0a1af9c2ce63ea1098fa88 --- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h | 5 +- .../gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 51 ++++++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 20 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h | 2 + drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 63 ++++++++++++++++--- drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 1 + drivers/gpu/drm/amd/amdkfd/kfd_process.c | 36 +++++++++-- 7 files changed, 159 insertions(+), 19 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h index 313ee49b9f17..158130a4f4cc 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h @@ -117,6 +117,7 @@ struct amdkfd_process_info { atomic_t evicted_bos; struct delayed_work restore_userptr_work; struct pid *pid; + bool block_mmu_notifications; }; int amdgpu_amdkfd_init(void); @@ -249,7 +250,9 @@ uint64_t amdgpu_amdkfd_gpuvm_get_process_page_dir(void *drm_priv); int amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu( struct kgd_dev *kgd, uint64_t va, uint64_t size, void *drm_priv, struct kgd_mem **mem, - uint64_t *offset, uint32_t flags); + uint64_t *offset, uint32_t flags, bool criu_resume); +void amdgpu_amdkfd_block_mmu_notifications(void *p); +int amdgpu_amdkfd_criu_resume(void *p); int amdgpu_amdkfd_gpuvm_free_memory_of_gpu( struct kgd_dev *kgd, struct kgd_mem *mem, void *drm_priv, uint64_t *size); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c index dfa025d694f8..ad8818844526 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c @@ -597,7 +597,8 @@ static void remove_kgd_mem_from_kfd_bo_list(struct kgd_mem *mem, * * Returns 0 for success, negative errno for errors. */ -static int init_user_pages(struct kgd_mem *mem, uint64_t user_addr) +static int init_user_pages(struct kgd_mem *mem, uint64_t user_addr, + bool criu_resume) { struct amdkfd_process_info *process_info = mem->process_info; struct amdgpu_bo *bo = mem->bo; @@ -619,6 +620,17 @@ static int init_user_pages(struct kgd_mem *mem, uint64_t user_addr) goto out; } + if (criu_resume) { + /* + * During a CRIU restore operation, the userptr buffer objects + * will be validated in the restore_userptr_work worker at a + * later stage when it is scheduled by another ioctl called by + * CRIU master process for the target pid for restore. + */ + atomic_inc(&mem->invalid); + mutex_unlock(&process_info->lock); + return 0; + } ret = amdgpu_ttm_tt_get_user_pages(bo, bo->tbo.ttm->pages); if (ret) { pr_err("%s: Failed to get user pages: %d\n", __func__, ret); @@ -982,6 +994,7 @@ static int init_kfd_vm(struct amdgpu_vm *vm, void **process_info, INIT_DELAYED_WORK(&info->restore_userptr_work, amdgpu_amdkfd_restore_userptr_worker); + info->block_mmu_notifications = false; *process_info = info; *ef = dma_fence_get(&info->eviction_fence->base); } @@ -1139,10 +1152,37 @@ uint64_t amdgpu_amdkfd_gpuvm_get_process_page_dir(void *drm_priv) return avm->pd_phys_addr; } +void amdgpu_amdkfd_block_mmu_notifications(void *p) +{ + struct amdkfd_process_info *pinfo = (struct amdkfd_process_info *)p; + + pinfo->block_mmu_notifications = true; +} + +int amdgpu_amdkfd_criu_resume(void *p) +{ + int ret = 0; + struct amdkfd_process_info *pinfo = (struct amdkfd_process_info *)p; + + mutex_lock(&pinfo->lock); + pr_debug("scheduling work\n"); + atomic_inc(&pinfo->evicted_bos); + if (!pinfo->block_mmu_notifications) { + ret = -EINVAL; + goto out_unlock; + } + pinfo->block_mmu_notifications = false; + schedule_delayed_work(&pinfo->restore_userptr_work, 0); + +out_unlock: + mutex_unlock(&pinfo->lock); + return ret; +} + int amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu( struct kgd_dev *kgd, uint64_t va, uint64_t size, void *drm_priv, struct kgd_mem **mem, - uint64_t *offset, uint32_t flags) + uint64_t *offset, uint32_t flags, bool criu_resume) { struct amdgpu_device *adev = get_amdgpu_device(kgd); struct amdgpu_vm *avm = drm_priv_to_vm(drm_priv); @@ -1247,7 +1287,8 @@ int amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu( add_kgd_mem_to_kfd_bo_list(*mem, avm->process_info, user_addr); if (user_addr) { - ret = init_user_pages(*mem, user_addr); + pr_debug("creating userptr BO for user_addr = %llu\n", user_addr); + ret = init_user_pages(*mem, user_addr, criu_resume); if (ret) goto allocate_init_user_pages_failed; } @@ -1742,6 +1783,10 @@ int amdgpu_amdkfd_evict_userptr(struct kgd_mem *mem, int evicted_bos; int r = 0; + /* Do not process MMU notifications until stage-4 IOCTL is received */ + if (process_info->block_mmu_notifications) + return 0; + atomic_inc(&mem->invalid); evicted_bos = atomic_inc_return(&process_info->evicted_bos); if (evicted_bos == 1) { diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index 7e7d8330d64b..99ea29fd12bd 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c @@ -1181,6 +1181,26 @@ static void amdgpu_ttm_tt_unpopulate(struct ttm_device *bdev, return ttm_pool_free(&adev->mman.bdev.pool, ttm); } +/** + * amdgpu_ttm_tt_get_userptr - Return the userptr GTT ttm_tt for the current + * task + * + * @tbo: The ttm_buffer_object that contains the userptr + * @user_addr: The returned value + */ +int amdgpu_ttm_tt_get_userptr(const struct ttm_buffer_object *tbo, + uint64_t *user_addr) +{ + struct amdgpu_ttm_tt *gtt; + + if (!tbo->ttm) + return -EINVAL; + + gtt = (void *)tbo->ttm; + *user_addr = gtt->userptr; + return 0; +} + /** * amdgpu_ttm_tt_set_userptr - Initialize userptr GTT ttm_tt for the current * task diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h index 9e38475e0f8d..dddd76f7a92e 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h @@ -168,6 +168,8 @@ static inline bool amdgpu_ttm_tt_get_user_pages_done(struct ttm_tt *ttm) #endif void amdgpu_ttm_tt_set_user_pages(struct ttm_tt *ttm, struct page **pages); +int amdgpu_ttm_tt_get_userptr(const struct ttm_buffer_object *tbo, + uint64_t *user_addr); int amdgpu_ttm_tt_set_userptr(struct ttm_buffer_object *bo, uint64_t addr, uint32_t flags); bool amdgpu_ttm_tt_has_userptr(struct ttm_tt *ttm); diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c index 95d81d00daa9..788baee2a025 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c @@ -1301,7 +1301,7 @@ static int kfd_ioctl_alloc_memory_of_gpu(struct file *filep, err = amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu( dev->kgd, args->va_addr, args->size, pdd->drm_priv, (struct kgd_mem **) &mem, &offset, - flags); + flags, false); if (err) goto err_unlock; @@ -1959,6 +1959,14 @@ static int kfd_ioctl_criu_dumper(struct file *filep, bo_bucket[i].gpu_id = pdd->dev->id; bo_bucket[i].bo_alloc_flags = (uint32_t)kgd_mem->alloc_flags; bo_bucket[i].idr_handle = id; + if (bo_bucket[i].bo_alloc_flags & KFD_IOC_ALLOC_MEM_FLAGS_USERPTR) { + ret = amdgpu_ttm_tt_get_userptr(&dumper_bo->tbo, + &bo_bucket[i].user_addr); + if (ret) { + pr_err("Failed to obtain user address for user-pointer bo\n"); + goto err_unlock; + } + } if (bo_bucket[i].bo_alloc_flags & KFD_IOC_ALLOC_MEM_FLAGS_DOORBELL) bo_bucket[i].bo_offset = KFD_MMAP_TYPE_DOORBELL | @@ -2004,6 +2012,7 @@ static int kfd_ioctl_criu_restorer(struct file *filep, struct kfd_criu_devinfo_bucket *devinfos = NULL; uint64_t *restored_bo_offsets_arr = NULL; struct kfd_criu_bo_buckets *bo_bucket = NULL; + const bool criu_resume = true; long err = 0; int ret, i, j = 0; @@ -2052,6 +2061,9 @@ static int kfd_ioctl_criu_restorer(struct file *filep, goto err_unlock; } + /* Prevent MMU notifications until stage-4 IOCTL is received */ + amdgpu_amdkfd_block_mmu_notifications(p->kgd_process_info); + /* Create and map new BOs */ for (i = 0; i < args->num_of_bos; i++) { struct kfd_dev *dev; @@ -2108,8 +2120,12 @@ static int kfd_ioctl_criu_restorer(struct file *filep, err = -ENOMEM; goto err_unlock; } + } else if (bo_bucket[i].bo_alloc_flags & + KFD_IOC_ALLOC_MEM_FLAGS_USERPTR) { + offset = bo_bucket[i].user_addr; } + /* Create the BO */ ret = amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu(dev->kgd, bo_bucket[i].bo_addr, @@ -2117,7 +2133,8 @@ static int kfd_ioctl_criu_restorer(struct file *filep, pdd->drm_priv, (struct kgd_mem **) &mem, &offset, - bo_bucket[i].bo_alloc_flags); + bo_bucket[i].bo_alloc_flags, + criu_resume); if (ret) { pr_err("Could not create the BO\n"); err = -ENOMEM; @@ -2230,6 +2247,40 @@ static int kfd_ioctl_criu_restorer(struct file *filep, return err; } +static int kfd_ioctl_criu_resume(struct file *filep, + struct kfd_process *p, void *data) +{ + struct kfd_ioctl_criu_resume_args *args = data; + struct kfd_process *target = NULL; + struct pid *pid = NULL; + int ret = 0; + + pr_debug("Inside %s, target pid for criu restore: %d\n", __func__, + args->pid); + + pid = find_get_pid(args->pid); + if (!pid) { + pr_err("Cannot find pid info for %i\n", args->pid); + return -ESRCH; + } + + pr_debug("calling kfd_lookup_process_by_pid\n"); + target = kfd_lookup_process_by_pid(pid); + if (!target) { + pr_debug("Cannot find process info for %i\n", args->pid); + put_pid(pid); + return -ESRCH; + } + + mutex_lock(&target->mutex); + ret = amdgpu_amdkfd_criu_resume(target->kgd_process_info); + mutex_unlock(&target->mutex); + + put_pid(pid); + kfd_unref_process(target); + return ret; +} + static int kfd_ioctl_criu_helper(struct file *filep, struct kfd_process *p, void *data) { @@ -2276,14 +2327,6 @@ static int kfd_ioctl_criu_helper(struct file *filep, return ret; } -static int kfd_ioctl_criu_resume(struct file *filep, - struct kfd_process *p, void *data) -{ - pr_info("Inside %s\n",__func__); - - return 0; -} - #define AMDKFD_IOCTL_DEF(ioctl, _func, _flags) \ [_IOC_NR(ioctl)] = {.cmd = ioctl, .func = _func, .flags = _flags, \ .cmd_drv = 0, .name = #ioctl} diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h index 9c675755369a..8278c43f4e50 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h +++ b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h @@ -937,6 +937,7 @@ void *kfd_process_device_translate_handle(struct kfd_process_device *p, int handle); void kfd_process_device_remove_obj_handle(struct kfd_process_device *pdd, int handle); +struct kfd_process *kfd_lookup_process_by_pid(struct pid *pid); bool kfd_has_process_device_data(struct kfd_process *p); diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process.c b/drivers/gpu/drm/amd/amdkfd/kfd_process.c index bc133c3789d8..bbf21395fb06 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_process.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_process.c @@ -65,7 +65,8 @@ static struct workqueue_struct *kfd_process_wq; */ static struct workqueue_struct *kfd_restore_wq; -static struct kfd_process *find_process(const struct task_struct *thread); +static struct kfd_process *find_process(const struct task_struct *thread, + bool ref); static void kfd_process_ref_release(struct kref *ref); static struct kfd_process *create_process(const struct task_struct *thread); static int kfd_process_init_cwsr_apu(struct kfd_process *p, struct file *filep); @@ -670,7 +671,8 @@ static int kfd_process_alloc_gpuvm(struct kfd_process_device *pdd, int err; err = amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu(kdev->kgd, gpu_va, size, - pdd->drm_priv, &mem, NULL, flags); + pdd->drm_priv, &mem, NULL, flags, + false); if (err) goto err_alloc_mem; @@ -773,7 +775,7 @@ struct kfd_process *kfd_create_process(struct file *filep) mutex_lock(&kfd_processes_mutex); /* A prior open of /dev/kfd could have already created the process. */ - process = find_process(thread); + process = find_process(thread, false); if (process) { pr_debug("Process already found\n"); } else { @@ -852,7 +854,7 @@ struct kfd_process *kfd_get_process(const struct task_struct *thread) if (thread->group_leader->mm != thread->mm) return ERR_PTR(-EINVAL); - process = find_process(thread); + process = find_process(thread, false); if (!process) return ERR_PTR(-EINVAL); @@ -871,13 +873,16 @@ static struct kfd_process *find_process_by_mm(const struct mm_struct *mm) return NULL; } -static struct kfd_process *find_process(const struct task_struct *thread) +static struct kfd_process *find_process(const struct task_struct *thread, + bool ref) { struct kfd_process *p; int idx; idx = srcu_read_lock(&kfd_processes_srcu); p = find_process_by_mm(thread->mm); + if (p && ref) + kref_get(&p->ref); srcu_read_unlock(&kfd_processes_srcu, idx); return p; @@ -1578,6 +1583,27 @@ void kfd_process_device_remove_obj_handle(struct kfd_process_device *pdd, idr_remove(&pdd->alloc_idr, handle); } +/* This increments the process->ref counter. */ +struct kfd_process *kfd_lookup_process_by_pid(struct pid *pid) +{ + struct task_struct *task = NULL; + struct kfd_process *p = NULL; + + if (!pid) { + task = current; + get_task_struct(task); + } else { + task = get_pid_task(pid, PIDTYPE_PID); + } + + if (task) { + p = find_process(task, true); + put_task_struct(task); + } + + return p; +} + /* This increments the process->ref counter. */ struct kfd_process *kfd_lookup_process_by_pasid(u32 pasid) { From patchwork Sat May 1 01:57:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Kuehling X-Patchwork-Id: 12234577 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=-13.7 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, UNWANTED_LANGUAGE_BODY,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 B6449C433B4 for ; Sat, 1 May 2021 01:58:46 +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 7E98C61409 for ; Sat, 1 May 2021 01:58:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7E98C61409 Authentication-Results: mail.kernel.org; dmarc=fail (p=none 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 439DD6F626; Sat, 1 May 2021 01:58:30 +0000 (UTC) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2078.outbound.protection.outlook.com [40.107.92.78]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4372D6F633; Sat, 1 May 2021 01:58:27 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lII7mjbV48xnscr4Qghgo9KhYu+np2/f0+ePB4/lJwXQUpLbDEwkrVSGWNHcqLIJ3rxDj/lOIOVlckwe16QMJ0Xi7pWpmfeL3pnZ325i6hH/BXN9qrxXEHs09YnBS6CO2Kp9YKUV4TZdaVtdXHst1W4jp/LVxpl6DHILdNgznzbIGoRRSodnFbnAJ88oXuji5+aPFDkSHsmRGTTNPe+Dnb0OU5YV2hr4oGAfLPXAradzGu+JhAousxJE8068PLLHg0k7Yx39hlj/RqWtnEhhx567xuyLulTZohny1IBjtYtrTCQjjWhrrETCWWyfRByDboSvuhGz59YxNNVPq+7Y9w== 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=HXUcnLOcggcN2WkbgiH6Iw1F6xdRywFWKJtwxKN2tCc=; b=ld1eRDl0ZSkhH45loP3InwHK0KGGipjQsBMcmcGLr+JaWHL2yDVIyTFi2DqNwSMutErRjm7K5TAgdmdIBWjuQANeHEjEjk763Xu9eGwjOnDrG8N1qmxQJp9BMJxRblU7JW8l88pNPk05fUprU7fylQHrLUsO41cj43mkpDHBFrwZbzPP0AdrMtxT3eyJo6K+Fy3w90OJwz5X37/vA/JaBsWh5rJCN8rMGH90j5uDm7DGlT2Qoll2MlK908pqzJiMzUsBA01iChIFCPPJbs2FZSIDKN4LG6K7i0omQCRSBzs3e5fuJNSVtjaB1aS9o8+IAaRAdk3zlOCPjTp0YXXsqA== 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=HXUcnLOcggcN2WkbgiH6Iw1F6xdRywFWKJtwxKN2tCc=; b=WY9cVWifBkenqt//vkj7G2TKyvNCC1FYEuai9LQ7tKnxmcZy/F9KA2mmALUYqF3D8bCCMV91sNeCp/YUmumRjFYMKUlcTbFLNx9Q3zQuKtuODLAoSwRynqJ3fYPgOPvNpDWFpOWrSa1wVf4vAFRjQR8LvE5TiVqzhl4BGlIYyqw= 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 BL0PR12MB4948.namprd12.prod.outlook.com (52.135.46.212) by MN2PR12MB4142.namprd12.prod.outlook.com (52.135.51.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.25; Sat, 1 May 2021 01:58:25 +0000 Received: from BL0PR12MB4948.namprd12.prod.outlook.com ([fe80::70f5:99ed:65a1:c033]) by BL0PR12MB4948.namprd12.prod.outlook.com ([fe80::70f5:99ed:65a1:c033%5]) with mapi id 15.20.4065.027; Sat, 1 May 2021 01:58:25 +0000 From: Felix Kuehling To: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [RFC PATCH 08/17] drm/amdkfd: CRIU add queues support Date: Fri, 30 Apr 2021 21:57:43 -0400 Message-Id: <20210501015752.888-9-Felix.Kuehling@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210501015752.888-1-Felix.Kuehling@amd.com> References: <20210501015752.888-1-Felix.Kuehling@amd.com> X-Originating-IP: [165.204.54.211] X-ClientProxiedBy: YT1PR01CA0037.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:2e::6) To BL0PR12MB4948.namprd12.prod.outlook.com (2603:10b6:208:1cc::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (165.204.54.211) by YT1PR01CA0037.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:2e::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.25 via Frontend Transport; Sat, 1 May 2021 01:58:24 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7fba8fd5-221a-447b-a813-08d90c449b4f X-MS-TrafficTypeDiagnostic: MN2PR12MB4142: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2MoId0dONm8LrcjdAXRQo1tYCtrGR8Lyu+rXAyLnn94Ms6IUq9IsWEO1Oq/Dwe+E2raeAjQjp6lnxV+hRby8GJUTgZDcWOQyuuREI5NGzcyqIJ7Xk5ugWpKIGdLEjSVWWwT5SKTx1WIZglB54A0jVardS/Uj/5oKrus1rGytrMoihK9bk2jSJKKn63StWcpYFVJQLMvVpgiqLUpyADmPkbqKkl5JNWzk2eDoWn2xYpTn12F+oGPzzyKMpNN0Hph0b3Y8QYaQjCOwKnepoogoiLjH+OZBDJp/N8tn5kOrxsZ4IsBC66qxS8oweewbSHCBuskHubipCUR98MCVVmy+/QHhcFjmp6UAA8/N1eXj1FBjEwPW1nCLLUnZdHbTL6ApRrhIzmBirCFupxPotlxvNugfG+4YlEYbscNz1YMhe9H6brc/o2EbdeAqXqrM8naBqOLQ5wGkGn6revjmSGoXpq6R15vOk/C3ZUlQUNDQyH1F3q+DBnE+EX/tAvEVaMVt3eKFQXy8Fp0SxzEGBfNZGpbsi0zuVYg8kboldZhzZrWceg4y+2L0IoRnzFxvW/FpSzrafnqn0Ci2iQlH+1agMoFv2RlmwecbTFvKV21oOdixKz/oSMQ4+VXNiOjKg+33JVdMf94SoLxlequBKjKJUuXp5Vvri4LueC/emEOkb+3xCrn/Dld0DdcnL6PcQOxK X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BL0PR12MB4948.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(346002)(366004)(396003)(39860400002)(136003)(66556008)(6506007)(2616005)(66946007)(66476007)(52116002)(956004)(38100700002)(6512007)(450100002)(4326008)(8676002)(8936002)(478600001)(2906002)(6486002)(86362001)(26005)(186003)(16526019)(83380400001)(5660300002)(1076003)(36756003)(6666004)(316002)(38350700002)(69590400013); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: DNT871V87sPPKi9CSPsIwg+045dy1ZiTNXY4w3XjcIs/NChRuq+Pon0Ems/dDyv/65pPnuSHo1+c308lZlhW0KsVwENXLDXDkrRzoVPsO6LfFYaKyCK/PkIOXOemQ1YdT7fy+Uyb0BIy5J8wakkm56aI1ZTOWxZ0zudRZF6FrsOT3u3lvE3eBVALXBNG5oDJ/c413Ai5KiZiExGfWPRslrt5NOWbkRf/woFnfomCjTf2jMTCOqNxHB2Z1yIzAUz7nKBYlCe1Im6wX3ngMYlniXfM3RVsTyJnkijgVwWYGLV0FHgKBLgDxWOnro82nUUAr2FNsJLwwg16SxaPHOpNmM2iqythS5alnE8c+vFf5XQ325I5ifMgQdJX7g2J/K2iVdxYImYLiEbifB04tfXMSEt9CnaIpQDXYLKOjNpzYO2ZVojTw+fzEO8Z+GqlZii00AfF3XkSRwhO/+pS+xOr6Mpc9S98CSLuILcMv1TPETWpYHStYpxWx703EtOSCzSUhrLQYJHDc4URYLlhfEkC9baWjNvR8yYL+cWTToJRhOznsYEmLTrl+Vn7rIVTJmGf0Ewv4ikwODqSMFhcjAaC2Kvn6qYPhnX1Dhpn0tWN+YXAtjxLmVyb3Cxntfe1T+qTuJJdP4RRzrEMXJrALpDL5x/jRML+9l1/KRIf1crAlVZmle12diym8nzW3l9FgO6PTl0UE2xEA0q08BvqAu8jB1DOTb1jhy6Somt0gjrEEu+XQcafO2FQaOGZs/hKll2MvfQ57BbXJxvL5hmD8qtuNcWm+SDpLBwf+4RINe0oZ5BgM8oy5NkMPUO3azSFcCbOOmsX23T/r4VRXgZ0jSTw5WKPwhgaXKbZIIBqfIswUlRAvWGEaKlZTWz3mJxkOU7sTG+BWRjJFXrAE44lmBsH8I6pvn/abUKd7M0+NqI+g9JxcRj9fanyAJ/3tRIF9fs8dTlPLfRb0ziaVfOTjjdBhBzKQ/8punG+iIBk7uEHFjkdlY6bNBUz3aKbCRl7W7UwBPBZTb7qJBGBYGhU4Xvpycwe/K1DrJO/5Mm6zNSrwecFtNSIAjEaCyBWnyl6LGEn7d7rXI7RN/hbS14OeIgLruiaF0nyktRqAekT3CJ1m92R8svVdTkORPT771dDvqBUVWTMQCsM9sAR13/SbcEDTucLduADH+ABQ66QKXw27AzqBKIMbuZxWRKNdZrp0//KNFs1EV7UVx57/zi8lT6xWwnNOK4cxRBsnQLMxyMTRophiwhvwS4hl6Chfwe0Y1iTeTUT1XGK9qSSr+nLc1MIAB9QvULmI+7BvIMEFRGZ+hcSWB9gPm7VfjSF5Yy1ImNA X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7fba8fd5-221a-447b-a813-08d90c449b4f X-MS-Exchange-CrossTenant-AuthSource: BL0PR12MB4948.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 May 2021 01:58:25.5481 (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: aIQCzruqZTr+6crLTr2lPMHRzWVBJbz67Dc0KV7zxyBdC3OwrhIXQN+7Nh6p+g6zdUKD9kSckdOVaujJy/z/nw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4142 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: David Yat Sin Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: David Yat Sin Add support to existing CRIU ioctl's to save number of queues and queue properties for each queue during checkpoint and re-create queues on restore. Signed-off-by: David Yat Sin Change-Id: Ifcd5e8359f492eef015867f354f44146dd1b6848 --- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 234 ++++++++++++++++++++++- 1 file changed, 231 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c index 788baee2a025..a9a04148e94c 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c @@ -1840,7 +1840,6 @@ static int kfd_devinfo_restore(struct kfd_process *p, struct kfd_criu_devinfo_bu uint32_t num_of_devices) { int i; - if (p->n_pdds != num_of_devices) return -EINVAL; @@ -1891,6 +1890,77 @@ static int kfd_devinfo_restore(struct kfd_process *p, struct kfd_criu_devinfo_bu } return 0; } +static void criu_dump_queue(struct kfd_process_device *pdd, + struct queue *q, + struct kfd_criu_q_bucket *q_bucket) +{ + q_bucket->gpu_id = pdd->dev->id; + q_bucket->type = q->properties.type; + q_bucket->format = q->properties.format; + q_bucket->q_id = q->properties.queue_id; + q_bucket->q_address = q->properties.queue_address; + q_bucket->q_size = q->properties.queue_size; + q_bucket->priority = q->properties.priority; + q_bucket->q_percent = q->properties.queue_percent; + q_bucket->read_ptr_addr = (uint64_t)q->properties.read_ptr; + q_bucket->write_ptr_addr = (uint64_t)q->properties.write_ptr; + q_bucket->doorbell_id = q->doorbell_id; + q_bucket->doorbell_off = q->properties.doorbell_off; + q_bucket->sdma_id = q->sdma_id; + + q_bucket->eop_ring_buffer_address = + q->properties.eop_ring_buffer_address; + + q_bucket->eop_ring_buffer_size = q->properties.eop_ring_buffer_size; + + q_bucket->ctx_save_restore_area_address = + q->properties.ctx_save_restore_area_address; + + q_bucket->ctx_save_restore_area_size = + q->properties.ctx_save_restore_area_size; + + q_bucket->ctl_stack_size = q->properties.ctl_stack_size; +} + +static int criu_dump_queues_device(struct kfd_process_device *pdd, + unsigned *q_index, + unsigned int max_num_queues, + struct kfd_criu_q_bucket *user_buckets) +{ + struct queue *q; + struct kfd_criu_q_bucket q_bucket; + int ret = 0; + + list_for_each_entry(q, &pdd->qpd.queues_list, list) { + if (q->properties.type != KFD_QUEUE_TYPE_COMPUTE && + q->properties.type != KFD_QUEUE_TYPE_SDMA && + q->properties.type != KFD_QUEUE_TYPE_SDMA_XGMI) { + + pr_err("Unsupported queue type (%d)\n", q->properties.type); + return -ENOTSUPP; + } + + if (*q_index >= max_num_queues) { + pr_err("Number of queues(%d) exceed allocated(%d)\n", + *q_index, max_num_queues); + + ret = -ENOMEM; + break; + } + + memset(&q_bucket, 0, sizeof(q_bucket)); + criu_dump_queue(pdd, q, &q_bucket); + ret = copy_to_user((void __user *)&user_buckets[*q_index], + &q_bucket, sizeof(q_bucket)); + if (ret) { + pr_err("Failed to copy queue information to user\n"); + ret = -EFAULT; + break; + } + *q_index = *q_index + 1; + } + return ret; +} static int kfd_ioctl_criu_dumper(struct file *filep, struct kfd_process *p, void *data) @@ -1900,8 +1970,13 @@ static int kfd_ioctl_criu_dumper(struct file *filep, struct amdgpu_bo *dumper_bo; int ret, id, index, i = 0; struct kgd_mem *kgd_mem; + int q_index = 0; void *mem; + struct kfd_criu_q_bucket *user_buckets = + (struct kfd_criu_q_bucket*) args->kfd_criu_q_buckets_ptr; + + pr_info("Inside %s\n",__func__); if (args->num_of_bos == 0) { @@ -1922,6 +1997,8 @@ static int kfd_ioctl_criu_dumper(struct file *filep, if (!bo_bucket) return -ENOMEM; + pr_debug("num of queues = %u\n", args->num_of_queues); + mutex_lock(&p->mutex); if (!kfd_has_process_device_data(p)) { @@ -1930,9 +2007,17 @@ static int kfd_ioctl_criu_dumper(struct file *filep, goto err_unlock; } + ret = kfd_process_evict_queues(p); + if (ret) { + pr_err("Failed to evict queues\n"); + goto err_unlock; + } + ret = kfd_devinfo_dump(p, args); - if (ret) + if (ret) { + pr_err("Failed to dump devices\n"); goto err_unlock; + } /* Run over all PDDs of the process */ for (index = 0; index < p->n_pdds; index++) { @@ -1989,6 +2074,11 @@ static int kfd_ioctl_criu_dumper(struct file *filep, i++; } } + + ret = criu_dump_queues_device(pdd, &q_index, + args->num_of_queues, user_buckets); + if (ret) + goto err_unlock; } ret = copy_to_user((void __user *)args->kfd_criu_bo_buckets_ptr, @@ -1996,15 +2086,131 @@ static int kfd_ioctl_criu_dumper(struct file *filep, (args->num_of_bos * sizeof(struct kfd_criu_bo_buckets))); kvfree(bo_bucket); + + kfd_process_restore_queues(p); mutex_unlock(&p->mutex); - return ret ? -EFAULT : 0; + return 0; err_unlock: + kfd_process_restore_queues(p); mutex_unlock(&p->mutex); pr_err("Dumper ioctl failed err:%d\n", ret); return ret; } +static void set_queue_properties_from_criu(struct queue_properties *qp, + struct kfd_criu_q_bucket *q_bucket) +{ + qp->is_interop = false; + qp->is_gws = q_bucket->is_gws; + qp->queue_percent = q_bucket->q_percent; + qp->priority = q_bucket->priority; + qp->queue_address = q_bucket->q_address; + qp->queue_size = q_bucket->q_size; + qp->read_ptr = (uint32_t *) q_bucket->read_ptr_addr; + qp->write_ptr = (uint32_t *) q_bucket->write_ptr_addr; + qp->eop_ring_buffer_address = q_bucket->eop_ring_buffer_address; + qp->eop_ring_buffer_size = q_bucket->eop_ring_buffer_size; + qp->ctx_save_restore_area_address = q_bucket->ctx_save_restore_area_address; + qp->ctx_save_restore_area_size = q_bucket->ctx_save_restore_area_size; + qp->ctl_stack_size = q_bucket->ctl_stack_size; + qp->type = q_bucket->type; + qp->format = q_bucket->format; +} + +/* criu_restore_queue runs with the process mutex locked */ +int criu_restore_queue(struct kfd_process *p, + struct kfd_dev *dev, + struct kfd_process_device *pdd, + struct kfd_criu_q_bucket *q_bucket) +{ + int ret = 0; + unsigned int queue_id; + struct queue_properties qp; + + pr_debug("Restoring Queue: gpu_id:%x type:%x format:%x queue_id:%u " + "address:%llx size:%llx priority:%u percent:%u " + "read_ptr:%llx write_ptr:%llx doorbell_id:%x " + "doorbell_off:%llx queue_address:%llx\n", + q_bucket->gpu_id, + q_bucket->type, + q_bucket->format, + q_bucket->q_id, + q_bucket->q_address, + q_bucket->q_size, + q_bucket->priority, + q_bucket->q_percent, + q_bucket->read_ptr_addr, + q_bucket->write_ptr_addr, + q_bucket->doorbell_id, + q_bucket->doorbell_off, + q_bucket->q_address); + + memset(&qp, 0, sizeof(qp)); + set_queue_properties_from_criu(&qp, q_bucket); + print_queue_properties(&qp); + + ret = pqm_create_queue(&p->pqm, dev, NULL, &qp, &queue_id, NULL); + if (ret) { + pr_err("Failed to create new queue err:%d\n", ret); + return -EINVAL; + } + pr_debug("Queue id %d was restored successfully\n", queue_id); + + return 0; +} + +/* criu_restore_queues runs with the process mutex locked */ +static int criu_restore_queues(struct kfd_process *p, + struct kfd_ioctl_criu_restorer_args *args) +{ + struct kfd_process_device *pdd; + struct kfd_dev *dev; + int i; + int ret; + struct kfd_criu_q_bucket *user_buckets = + (struct kfd_criu_q_bucket*) args->kfd_criu_q_buckets_ptr; + /* + * This process will not have any queues at this point, but we are + * setting all the dqm's for this process to evicted state. + */ + kfd_process_evict_queues(p); + + for (i = 0; i < args->num_of_queues; i++) { + struct kfd_criu_q_bucket q_bucket; + ret = copy_from_user(&q_bucket, (void __user *)&user_buckets[i], + sizeof(struct kfd_criu_q_bucket)); + + if (ret) { + ret = -EFAULT; + pr_err("Failed to access"); + return ret; + } + + dev = kfd_device_by_id(q_bucket.gpu_id); + if (!dev) { + pr_err("Could not get kfd_dev from gpu_id = 0x%x\n", + q_bucket.gpu_id); + + ret = -EINVAL; + return ret; + } + + pdd = kfd_get_process_device_data(dev, p); + if (!pdd) { + pr_err("Failed to get pdd\n"); + ret = -EFAULT; + return ret; + } + ret = criu_restore_queue(p, dev, pdd, &q_bucket); + if (ret) { + pr_err("Failed to restore queue (%d)\n", ret); + break; + } + } + return ret; +} + static int kfd_ioctl_criu_restorer(struct file *filep, struct kfd_process *p, void *data) { @@ -2229,6 +2435,12 @@ static int kfd_ioctl_criu_restorer(struct file *filep, kfd_flush_tlb(peer_pdd); } + ret = criu_restore_queues(p, args); + if (ret) { + err = ret; + goto err_unlock; + } + ret = copy_to_user((void __user *)args->restored_bo_array_ptr, restored_bo_offsets_arr, (args->num_of_bos * sizeof(*restored_bo_offsets_arr))); @@ -2286,8 +2498,10 @@ static int kfd_ioctl_criu_helper(struct file *filep, { struct kfd_ioctl_criu_helper_args *args = data; struct kgd_mem *kgd_mem; + struct queue *q; u64 num_of_bos = 0; int id, i = 0; + u32 q_index = 0; void *mem; int ret = 0; @@ -2314,12 +2528,26 @@ static int kfd_ioctl_criu_helper(struct file *filep, if ((uint64_t)kgd_mem->va > pdd->gpuvm_base) num_of_bos++; } + + list_for_each_entry(q, &pdd->qpd.queues_list, list) { + if (q->properties.type == KFD_QUEUE_TYPE_COMPUTE || + q->properties.type == KFD_QUEUE_TYPE_SDMA || + q->properties.type == KFD_QUEUE_TYPE_SDMA_XGMI) { + + q_index++; + } else { + pr_err("Unsupported queue type (%d)\n", q->properties.type); + ret = -ENOTSUPP; + goto err_unlock; + } + } } args->task_pid = task_pid_nr_ns(p->lead_thread, task_active_pid_ns(p->lead_thread)); args->num_of_devices = p->n_pdds; args->num_of_bos = num_of_bos; + args->num_of_queues = q_index; dev_dbg(kfd_device, "Num of bos = %llu\n", num_of_bos); err_unlock: From patchwork Sat May 1 01:57:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Kuehling X-Patchwork-Id: 12234579 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=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 04165C43461 for ; Sat, 1 May 2021 01:58:49 +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 CA4E861407 for ; Sat, 1 May 2021 01:58:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CA4E861407 Authentication-Results: mail.kernel.org; dmarc=fail (p=none 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 F17806F636; Sat, 1 May 2021 01:58:30 +0000 (UTC) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2042.outbound.protection.outlook.com [40.107.92.42]) by gabe.freedesktop.org (Postfix) with ESMTPS id 85CB56F626; Sat, 1 May 2021 01:58:29 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OScA+pCxFt6zg/ly5sdjZhT2jpyv0gifPg9wcEX4hJnePlb8Jjtuls/JhC2rFhS8AlcBqCd25DkutQBzV1QbE8G589CooyhK63DUFG49TfM+KNGCllL9KYbmP/scypFTibNOSGD6pwMW+ZI/2x4ep+VhbiUJHairmKWSiLlyBXurkdDkUJD+E9cL7/hCdK+6txVdntUlOKW4lxAKuMZS7C3iScySmeB24+3EJ9RJkuQOGOwVt7QM13yoZ3/J25MctGZSYrbzRHdn021oUuovQNiMhWbQcYs5V8P1ZfOhzquIhozf89XHUkvH7EOct2TQj+5CMPYyE6Ywxufi+cogEQ== 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=P8no+FGVa0f9KK6HgvK0PnemaMs9dnFnrsvq694xj+8=; b=iUC0ov0tni4wRTtDWHh58MPCo53rvOacTMg9RcnQERO59Es0fl2LDn6PhR2omfhkNtpf3cZlUWdPdml3yUYz1loZtpvlKCTEgv4IVCwhwwMgYmOgPkTkZmIAVtqyzei7z+WalK5OWL5bzHzXa5UZAq8SEtS6mAL6nUs3UYhpSOC3lu85Dt4LV0J3y8Y9pEQkN5mZ1lQAftYjLFoxlI6KckECvTcYVix0NmK7viVxgZFI7U/xW398gProxUNLtH+TiyvNu/xiDpAb5w7R6N+hHHSKxBFr2COcYJSdAT4lice0hHF+LGca0bfNPCjdSzA7c8wRpImJXATyYVu69IrqPg== 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=P8no+FGVa0f9KK6HgvK0PnemaMs9dnFnrsvq694xj+8=; b=nV5bff24T2/pZiRSzzuzqBqWOmaSu0pNLwN8N9yIJgaJBz80njtAqVPx8NAJ/cfDLSsH2LlgLeeenMyZQkc8zD36II0mlFKDitNE9eKSN6RGMNp8RBUzeFnjqKCRusvhTVLvDhJP58hdRq06G1glFTgqqIA6PLzKCenBre1RFSc= 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 BL0PR12MB4948.namprd12.prod.outlook.com (2603:10b6:208:1cc::20) by BL0PR12MB4898.namprd12.prod.outlook.com (2603:10b6:208:1c7::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.26; Sat, 1 May 2021 01:58:26 +0000 Received: from BL0PR12MB4948.namprd12.prod.outlook.com ([fe80::70f5:99ed:65a1:c033]) by BL0PR12MB4948.namprd12.prod.outlook.com ([fe80::70f5:99ed:65a1:c033%5]) with mapi id 15.20.4065.027; Sat, 1 May 2021 01:58:26 +0000 From: Felix Kuehling To: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [RFC PATCH 09/17] drm/amdkfd: CRIU restore queue ids Date: Fri, 30 Apr 2021 21:57:44 -0400 Message-Id: <20210501015752.888-10-Felix.Kuehling@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210501015752.888-1-Felix.Kuehling@amd.com> References: <20210501015752.888-1-Felix.Kuehling@amd.com> X-Originating-IP: [165.204.54.211] X-ClientProxiedBy: YT1PR01CA0037.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:2e::6) To BL0PR12MB4948.namprd12.prod.outlook.com (2603:10b6:208:1cc::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (165.204.54.211) by YT1PR01CA0037.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:2e::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.25 via Frontend Transport; Sat, 1 May 2021 01:58:25 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ed68cd14-cd48-48fd-7288-08d90c449bec X-MS-TrafficTypeDiagnostic: BL0PR12MB4898: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:454; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EDjpB+Gt43mMa7yI9OH9XuTkgaXyxUZPpPFqA+/B5JnvoEmr9OdvGt4coMWeot49+EdtA40ZG2qJ1gqGWhEu0/UR6boMB5uieotxIcsy8BJrmMkrWOYClVfkh8cOYzkaXRH1a07OezZG9t0EPH1k9fkdnr+4eGsmXmJrVcxqZaLWu0xj2uooU51ohO5ebqWr7/+Zs28/SXuKX5UkvGm47LTUwg+IOi0RZrS37B181MsCqjGOwQJs6xUjNKwxCzCK2aTSQFC17th3w6lHXyAv5QlUAnvXdyyx7MBkYepV2gR25jfwYxIt9wSP2K+4XMO3r/P9UJXUQ/utRGHUfJKDp6arbqWaIjm2OvsXDmmeusMcPSFd53e6kbtnUWVS+KviGjmpLwJkx5smJzwdcwTvSLLhv8K0oD9J4shWyjuQ6liqVBOEDyq28w62JlGBN5b/Ri/WbME8IMBevG2QSNCfUiq5HtvEgNsYmiwgf8c10mWJjj9AcGgUJR5lXPlsRZJS2HoJ3aETOMvpclCUb22hhP00vGc6yE5Pf50vY3ZFWiiRT3DPmliLiJwsch++goaAb8bTUIpZXKqTI0OwMCUvpgVsGFCU2fQViMmSVf2V4VmfCagkimP21q1J4+04VPmSpUaLtfpGeC6pwjk9XwFb3oMNn3E1YQN1fHhNePcSOjIe1pKCwIjhnKEfW2E+Y2Ab X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BL0PR12MB4948.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(136003)(346002)(39860400002)(396003)(366004)(36756003)(66556008)(66476007)(66946007)(6512007)(86362001)(8936002)(52116002)(478600001)(5660300002)(8676002)(6506007)(6666004)(38350700002)(38100700002)(2616005)(450100002)(4326008)(83380400001)(54906003)(1076003)(2906002)(26005)(16526019)(6486002)(956004)(316002)(186003)(69590400013); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: s9ciD7VFqEw+TRQsxILNj+ojYQzOaxXh9tQmrqjL2LxQHJOFI1gcfD2BSlbEegse9sapOwLRn+V7e8Djlw4V7kf9kGi1UJ1Gi3IHTOobWU0k90dVjuJfV12I7l2axaMIaZr84aJ84WeqdnmuL2BQadJ6rz71tGNg8wSYokueEbdI4EjWlIumHV41afOCdAnEQiMYzX71DqkZ4s/BWa6zPT3FwZdleB3GNq2wHK5DgTiwORfnq3KQLH9BE1aWkuiDRqtwRHx2mh8f/b5GivJlRjrJg0NU7bKKt2HBWmXf7TfrTNkZ095gMFihf+FEBHkc+7TtUXx54Q52qR6/NXH/w2F9XhQQFWK+crqMnyUga6cKg8+1M0gv9J0miumlwPZEMRi0kqEKKlYTYPXvKbzHjdxmeJ8G9SlE0Evheo5QbjqKx0fireDDNXaOxP0LO6AK7+3Gg6E8LwDt+3DOXSDzCCcwWBplwHnJ9vRFm0XHV2Drlaz+29zjb1LD8FxUFzppAg7PvbVCMLd+/cHqZHmHhhQ6XkkBC6b5Ol8sGXfaeRiSMmRyLl8zwfW9WALf+7A9zn9jsvwAqWaNWXUzpdxSVOPATZWzBJMHGx6xnHbLj4LdqopK9OQqYIcvEkZ5EaVWxMxw6JEjffylbxBu9TOGcC2ge8x+uaHYL5ygPzQTSRUpbaZdGpyDAiAImjRA8CvxO7v8O48FTvzV3GQ8dAK/ZjV/6STSjmtuMV3uOnGBmqSCiVwq6ai0rIV2SFyZ7LbUfstDXMyWJgxTShJ6HgAVbu/YhJmoW37UQK0dnlKEIIBYgD37zKEwM4UHne2S4XaZUd3NQt1gdbpXlOk619N1dSiPUoBspdKcDOOBlUaSaJ43wk6QyEJCLOypK67/pZBYZnMYT+Gt/XewlVWsA1QyJ8qeG2gcVccPn5V4ZheCL8/a0SIB0wOdm2CHbmL4zpbBt2208BtxqAxu3GDngQP51Z9CYjcT7pbhevARSVzjySdaQ2YQZqKtqjWjiB/46eKmYmdF1c0WXSVUXmW0UmXkMaMh5p41OGBcJo4fq3kmdrfb16wGstGMqw7ZgFYadoeBaP8he+tBd7ndI1LHx/Vwl2fyzQUpc8Zvg9yYrEfiWOWxPxQRaPhba1v/CFu8hhVu8zmsX4jnrh6M1Q/gIQd2F3E53cfzQcpHDmQzt1YHBbYqgEmvQVOZLtbn7Qp/K5SyIKRrW5rYI5ZNVUuyMAAvqmyIf5TxpQ0NneaZKGUMA986I3ENW4wkIeDzWsKWoHFQxN++hJx6zjJWMt7ZzxGDMj2dDxi4JuCjU2Ck+yf+9v8Acav+Ny1TNRuljq40sDpS X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: ed68cd14-cd48-48fd-7288-08d90c449bec X-MS-Exchange-CrossTenant-AuthSource: BL0PR12MB4948.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 May 2021 01:58:26.5279 (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: psTwanD4cCXdJvrJ37KYBjCjX+nklVwSB2rLEjQKVDJmD5BpF2sMuN0Fl8YOzyrhIpI7/sb4iqKaHgpXbhwJ0w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR12MB4898 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: David Yat Sin , Rajneesh Bhardwaj Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: David Yat Sin When re-creating queues during CRIU restore, restore the queue with the same queue id value used during CRIU dump. Adding a new private structure queue_restore_data to store queue restore information. Signed-off-by: Rajneesh Bhardwaj Signed-off-by: David Yat Sin Change-Id: I6959da5d3aeebe5be6623483883ef79676591134 --- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 18 ++++++++++----- drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c | 2 +- drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 6 +++++ .../amd/amdkfd/kfd_process_queue_manager.c | 22 ++++++++++++++++++- 4 files changed, 41 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c index a9a04148e94c..a21d32ff0730 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c @@ -313,7 +313,7 @@ static int kfd_ioctl_create_queue(struct file *filep, struct kfd_process *p, dev->id); err = pqm_create_queue(&p->pqm, dev, filep, &q_properties, &queue_id, - &doorbell_offset_in_process); + NULL, &doorbell_offset_in_process); if (err != 0) goto err_create_queue; @@ -1905,7 +1905,7 @@ static void criu_dump_queue(struct kfd_process_device *pdd, q_bucket->read_ptr_addr = (uint64_t)q->properties.read_ptr; q_bucket->write_ptr_addr = (uint64_t)q->properties.write_ptr; q_bucket->doorbell_id = q->doorbell_id; - q_bucket->doorbell_off = q->properties.doorbell_off; + q_bucket->sdma_id = q->sdma_id; q_bucket->eop_ring_buffer_address = @@ -2122,7 +2122,8 @@ static void set_queue_properties_from_criu(struct queue_properties *qp, int criu_restore_queue(struct kfd_process *p, struct kfd_dev *dev, struct kfd_process_device *pdd, - struct kfd_criu_q_bucket *q_bucket) + struct kfd_criu_q_bucket *q_bucket, + struct queue_restore_data *qrd) { int ret = 0; unsigned int queue_id; @@ -2150,11 +2151,14 @@ int criu_restore_queue(struct kfd_process *p, set_queue_properties_from_criu(&qp, q_bucket); print_queue_properties(&qp); - ret = pqm_create_queue(&p->pqm, dev, NULL, &qp, &queue_id, NULL); + qrd->qid = q_bucket->q_id; + + ret = pqm_create_queue(&p->pqm, dev, NULL, &qp, &queue_id, qrd, NULL); if (ret) { pr_err("Failed to create new queue err:%d\n", ret); return -EINVAL; } + pr_debug("Queue id %d was restored successfully\n", queue_id); return 0; @@ -2178,6 +2182,10 @@ static int criu_restore_queues(struct kfd_process *p, for (i = 0; i < args->num_of_queues; i++) { struct kfd_criu_q_bucket q_bucket; + struct queue_restore_data qrd; + + memset(&qrd, 0, sizeof(qrd)); + ret = copy_from_user(&q_bucket, (void __user *)&user_buckets[i], sizeof(struct kfd_criu_q_bucket)); @@ -2202,7 +2210,7 @@ static int criu_restore_queues(struct kfd_process *p, ret = -EFAULT; return ret; } - ret = criu_restore_queue(p, dev, pdd, &q_bucket); + ret = criu_restore_queue(p, dev, pdd, &q_bucket, &qrd); if (ret) { pr_err("Failed to restore queue (%d)\n", ret); break; diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c b/drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c index 159add0f5aaa..749a7a3bf191 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c @@ -185,7 +185,7 @@ static int dbgdev_register_diq(struct kfd_dbgdev *dbgdev) properties.type = KFD_QUEUE_TYPE_DIQ; status = pqm_create_queue(dbgdev->pqm, dbgdev->dev, NULL, - &properties, &qid, NULL); + &properties, &qid, NULL, NULL); if (status) { pr_err("Failed to create DIQ\n"); diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h index 8278c43f4e50..d21b7eb08a76 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h +++ b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h @@ -468,6 +468,11 @@ enum KFD_QUEUE_PRIORITY { * it's user mode or kernel mode queue. * */ + +struct queue_restore_data { + uint32_t qid; +}; + struct queue_properties { enum kfd_queue_type type; enum kfd_queue_format format; @@ -1055,6 +1060,7 @@ int pqm_create_queue(struct process_queue_manager *pqm, struct file *f, struct queue_properties *properties, unsigned int *qid, + const struct queue_restore_data *qrd, uint32_t *p_doorbell_offset_in_process); int pqm_destroy_queue(struct process_queue_manager *pqm, unsigned int qid); int pqm_update_queue(struct process_queue_manager *pqm, unsigned int qid, diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c index 95a6c36cea4c..cb136e13baff 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c @@ -42,6 +42,20 @@ static inline struct process_queue_node *get_queue_by_qid( return NULL; } +static int assign_queue_slot_by_qid(struct process_queue_manager *pqm, + unsigned int qid) +{ + if (qid >= KFD_MAX_NUM_OF_QUEUES_PER_PROCESS) + return -EINVAL; + + if (__test_and_set_bit(qid, pqm->queue_slot_bitmap)) { + pr_err("Cannot create new queue because requested qid(%u) is in use\n", qid); + return -ENOSPC; + } + + return 0; +} + static int find_available_queue_slot(struct process_queue_manager *pqm, unsigned int *qid) { @@ -193,6 +207,7 @@ int pqm_create_queue(struct process_queue_manager *pqm, struct file *f, struct queue_properties *properties, unsigned int *qid, + const struct queue_restore_data *qrd, uint32_t *p_doorbell_offset_in_process) { int retval; @@ -224,7 +239,12 @@ int pqm_create_queue(struct process_queue_manager *pqm, if (pdd->qpd.queue_count >= max_queues) return -ENOSPC; - retval = find_available_queue_slot(pqm, qid); + if (qrd) { + retval = assign_queue_slot_by_qid(pqm, qrd->qid); + *qid = qrd->qid; + } else + retval = find_available_queue_slot(pqm, qid); + if (retval != 0) return retval; From patchwork Sat May 1 01:57:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Kuehling X-Patchwork-Id: 12234575 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=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 9DD04C433B4 for ; Sat, 1 May 2021 01:58:43 +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 68D6B613F7 for ; Sat, 1 May 2021 01:58:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 68D6B613F7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none 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 194416F637; Sat, 1 May 2021 01:58:31 +0000 (UTC) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2042.outbound.protection.outlook.com [40.107.92.42]) by gabe.freedesktop.org (Postfix) with ESMTPS id B17956F636; Sat, 1 May 2021 01:58:29 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lnFrHVi+qam7t0yeEEeG+v5+cXgcGpyR5D8kcLWfpw6yAdLxtAPkLo2iV4Am2twOWaoIrzfRuOC1c9jX8fD2CxwmQLOcy6QtNoRnjD8bsh/cnYjYjSlcocPBy6UlVrRP6xwCN0enN9/3zDKbfAU81e/FfWAHEZKu49rHFZ9gy8X5AJFjjdeIGwdc7TZm+ge/fIZtHxzVmg9tov85uDu4AtZnva3W3GTElVErVMA1BU00SmGJ9/r8YNhvhqRMvn2k/7DM2LzwXRoVhxdXTeJmK6RiTejLP9YS+Si9PzhV7A1if96kfjbi+e7hJOS542H/vYa+S9RQL8S7SXlytZ6EUA== 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=e3q/MjEL1tMUIjXd7tzk38queuoj3wKPes59TV2J/J8=; b=L7n1lbVXZqB6SZeWwQHm+Xi1yNFe5Vo46eKplfG4pwO+jzmPCDsbtv881D3uqRGg5+QDvZ+ojEWHbQ+nUgq0LEEMAXBzx4fXNJLdIjEoL6CUNC3kSh7O2YTCVu1vwerhgwF/85B1DMu1996bB/2oJLAMbzTqxd/5e8aaovUW7PpTQLVCh+m9ggjcUK4Dvlfn33fX1BADUFOvQDbpIZ5rqUvWODTGhQU9dnHj3rR+s+yt4pd7CRURlBcGFSjkkQ78bAjJ86W6KmJnzvUz8Y6ktXoLYphm0I8ZAFt45froiayORrl4zdUYCtcN565WODXS02qpILStc2YhkJRqeNUXUw== 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=e3q/MjEL1tMUIjXd7tzk38queuoj3wKPes59TV2J/J8=; b=aGSpeGyDcYeFGZ6i6Rhd8PXDi8CNTIwDFLrPEHFetfV+gYqZ+oX643LrWJptfpHjveKAP1TO53oYSn9KjGdLY9bQx/K++gKQW9Y7UIUtEy53pJ0zAIT5Ul6Y/O8lPOTtR7O1nrhMo/wPu8f/uGi/HS2Zyxu2Sfi5PpFvOowx2sQ= 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 BL0PR12MB4948.namprd12.prod.outlook.com (2603:10b6:208:1cc::20) by BL0PR12MB4898.namprd12.prod.outlook.com (2603:10b6:208:1c7::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.26; Sat, 1 May 2021 01:58:27 +0000 Received: from BL0PR12MB4948.namprd12.prod.outlook.com ([fe80::70f5:99ed:65a1:c033]) by BL0PR12MB4948.namprd12.prod.outlook.com ([fe80::70f5:99ed:65a1:c033%5]) with mapi id 15.20.4065.027; Sat, 1 May 2021 01:58:27 +0000 From: Felix Kuehling To: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [RFC PATCH 10/17] drm/amdkfd: CRIU restore sdma id for queues Date: Fri, 30 Apr 2021 21:57:45 -0400 Message-Id: <20210501015752.888-11-Felix.Kuehling@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210501015752.888-1-Felix.Kuehling@amd.com> References: <20210501015752.888-1-Felix.Kuehling@amd.com> X-Originating-IP: [165.204.54.211] X-ClientProxiedBy: YT1PR01CA0037.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:2e::6) To BL0PR12MB4948.namprd12.prod.outlook.com (2603:10b6:208:1cc::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (165.204.54.211) by YT1PR01CA0037.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:2e::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.25 via Frontend Transport; Sat, 1 May 2021 01:58:26 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 17f07178-386d-47d0-7130-08d90c449c91 X-MS-TrafficTypeDiagnostic: BL0PR12MB4898: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2582; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fNPOffaSKZ8sGgdkH/+778IBgicE/8AoHp4nT6ILXuRtG9B3oMA1BBQ6Fe0F6vE1Ctlr77MDZDIlLjPNoDxpt8LShgrJEGSMjZweb5YiytWUdMwB5w0DsFvGVwDSNw4kFDb30LAozLfJWkBqNmQ1/bnB/AJRyZmjWP7pCOP8TEmmo0Kvkh89wNbZKmxWRq5c3lu7LxL5YdD3TfNuc6fbTPUuJF9g1PJ1aXHEkiPXrQxcy8XmlZLcHFM+j88lTaQMQQvovjjro4RkUj+nvSXzz91a/Ejq+/wSXWDsKn9RCCtf5fy+YR/LHZVART4QQRvx4TLwJOYeDgrta0DI+NkFaZVofMpi/c8DE41ATe6whdPDVEs6SacCacVZKCWVbWm47qBbZGILNV74Vx+UjDqvJhc1iwUFVCo8LO7bdq/7XEs8gkubvvEufCeHfdnIcGHHG/oelchTvMK1jQAxTn1V4BYoMm9xu9NiQoqGJg4GashKxYZPgHFGURIl0/fa0y+8u4zO3ck3HmPZV6f/fTeIJK4iUiP58TURT2UYNh1d9fRzw6j6gC+qIgjpd9kirh3WazF8WT3AH/Vnuxs9ZNy+MI2igazYzK6vC4/GF3hbVWEv5Xq9ZUG9El6YkPwsexo7WpoRoQ3aLC9+G0ux5eDP+TaO79wSK0f2zliE6MB60VRw5MwAGhCLim7gcY7GKbK6 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BL0PR12MB4948.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(136003)(346002)(39860400002)(396003)(366004)(36756003)(66556008)(66476007)(66946007)(6512007)(86362001)(8936002)(52116002)(478600001)(5660300002)(8676002)(6506007)(6666004)(38350700002)(38100700002)(2616005)(450100002)(4326008)(83380400001)(1076003)(2906002)(26005)(16526019)(6486002)(956004)(316002)(186003)(69590400013); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: aCjfFLHuB2SgN9suZ9y0nbIRi8yZpeyChLejRnBRN/+mqQGyOQh0eF6ljX1oczLmyMdaVVQ8jK1WuSMdr+LdGt1SNDykVKi5TfQGMT3QjlRdQS5oOBIH6l+Emwf16Myi7pCIzRI6n/sWNhwOnQRRNEhJH+Ef6rflEWt/qcaR39YxnFhuNJZ+B7wgitGANb/CJ1izalGLK+RlxGx8/eS7n2lXfcnKlayHeI5fHYWa03AyC4/h3ezNDpA92GUyBY3a+yVSuPfKypbYNnVf+glW9k3yu3SH7NSWhXbm7OZmQZHcCv8mtEO6/FibR4DWZzaPvHMOCarjPmDkTCGCJET05ZmlYr968xQHUPhbSFhKXhvCtzQWHvrMlOu/GAGdmrtzkg8PM8DrLcU9Tpt3DX1QSDdHTHnXZiFAxEuuLzI59xnfWTXWNg4aq9RLg7s/PGZ2eSmKbYN2NFPpE2RZW+wcCbA6okWdP73zjUiOpeeKRXsjaWgdSHB9bNdQGqubWr4jg+XaYtXAhK/sZCvMtoWXg5pJFv90ZR9UuAKZr0LnX1VRkWQvIRrakWZYelG336KRPslPNyPCYO2QviV6d9S9nwYWqFspLn1Jsh9h6VNPVU9klPwJ+s43CqpyOvGLByb1WJ7Z6aUwcz9GNESurUBwU5bUKKeL9ijUiKs1V72E5ruKtmYYrFsgLSgBmECh8JoNPvwZH26h77qjA31STmC8tgc6fhKZPlgICWZWIJ1kN39pwM/z6y3V/omxRLz5zHVeBEISYvhCn/Du+gECWz9YI/zfyYpo7IuZwEDM0D3+PCJskMaY7U+FG7Ccwdbg+KYiCcOkSkQMHEnBUmSkGhU+JPt9qKkJEyNlBrWd1Dm/odYmkPz8jjDWb7Mk2IA02nCLBe0xRif+Uifli9EbpaHI3ozEDQhPinLnFEsIGjDymr7tzISsnrQU2O5jPMqeelwyS5IOlwwFRcIdr6wLNRBPBbd600WQxWkguVzkrzBtBa5JHqwrgr4axkAGPkh7sSO0UntfZHWN8lXNyh4PM0gmaNF4WRb8Th4skErqo+hxp4w/NfMHOGfiE9saCcv/yqw0hB35GvMOVhaXuOZsXKyF359eaB9cW+ZU1XEI2Tzb5GZ2JIcPvCUDbG8zXKgnFax3+HfcrtevFRIysJLCpezDbZ3o3DiLuLsNYv/73F4dGr5MrccZi85DcXkozSNvCvqdI8FKNlL58/F5SJ1AJC4BEX7OtYs8t/VQrU3OMIj3Gtju24dZ1Ex6qcXW3nUmrlMxmetC86jAVtClbBqqyFUDxHJ4Gz2eqdUDOC4bwUvo+0Qi1xLbEHYyM+z4ultxxp4E X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 17f07178-386d-47d0-7130-08d90c449c91 X-MS-Exchange-CrossTenant-AuthSource: BL0PR12MB4948.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 May 2021 01:58:27.7376 (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: PWi5aBEJd3ssFFYiELKC/yGTd4wkM7AU3kOWjECshoFVMuJt8QDHCZcAWSnbbtYuFNnP6AOFLp72I8sT6MVWQw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR12MB4898 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: David Yat Sin Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: David Yat Sin When re-creating queues during CRIU restore, restore the queue with the same sdma id value used during CRIU dump. Signed-off-by: David Yat Sin Change-Id: I8ed667edb8b9b7b5089e59b78de9be80493a2808 --- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 1 + .../drm/amd/amdkfd/kfd_device_queue_manager.c | 48 ++++++++++++++----- .../drm/amd/amdkfd/kfd_device_queue_manager.h | 3 +- drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 1 + .../amd/amdkfd/kfd_process_queue_manager.c | 4 +- 5 files changed, 42 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c index a21d32ff0730..afcbdae436fa 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c @@ -2152,6 +2152,7 @@ int criu_restore_queue(struct kfd_process *p, print_queue_properties(&qp); qrd->qid = q_bucket->q_id; + qrd->sdma_id = q_bucket->sdma_id; ret = pqm_create_queue(&p->pqm, dev, NULL, &qp, &queue_id, qrd, NULL); if (ret) { diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c index 98c2046c7331..cabdfbacce37 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c @@ -58,7 +58,7 @@ static inline void deallocate_hqd(struct device_queue_manager *dqm, struct queue *q); static int allocate_hqd(struct device_queue_manager *dqm, struct queue *q); static int allocate_sdma_queue(struct device_queue_manager *dqm, - struct queue *q); + struct queue *q, const uint32_t *restore_sdma_id); static void kfd_process_hw_exception(struct work_struct *work); static inline @@ -296,7 +296,8 @@ static void deallocate_vmid(struct device_queue_manager *dqm, static int create_queue_nocpsch(struct device_queue_manager *dqm, struct queue *q, - struct qcm_process_device *qpd) + struct qcm_process_device *qpd, + const struct queue_restore_data *qrd) { struct mqd_manager *mqd_mgr; int retval; @@ -336,7 +337,7 @@ static int create_queue_nocpsch(struct device_queue_manager *dqm, q->pipe, q->queue); } else if (q->properties.type == KFD_QUEUE_TYPE_SDMA || q->properties.type == KFD_QUEUE_TYPE_SDMA_XGMI) { - retval = allocate_sdma_queue(dqm, q); + retval = allocate_sdma_queue(dqm, q, qrd ? &qrd->sdma_id : NULL); if (retval) goto deallocate_vmid; dqm->asic_ops.init_sdma_vm(dqm, q, qpd); @@ -1022,7 +1023,7 @@ static void pre_reset(struct device_queue_manager *dqm) } static int allocate_sdma_queue(struct device_queue_manager *dqm, - struct queue *q) + struct queue *q, const uint32_t *restore_sdma_id) { int bit; @@ -1032,9 +1033,21 @@ static int allocate_sdma_queue(struct device_queue_manager *dqm, return -ENOMEM; } - bit = __ffs64(dqm->sdma_bitmap); - dqm->sdma_bitmap &= ~(1ULL << bit); - q->sdma_id = bit; + if (restore_sdma_id) { + /* Re-use existing sdma_id */ + if (!(dqm->sdma_bitmap & (1ULL << *restore_sdma_id))) { + pr_err("SDMA queue already in use\n"); + return -EBUSY; + } + dqm->sdma_bitmap &= ~(1ULL << *restore_sdma_id); + q->sdma_id = *restore_sdma_id; + } else { + /* Find first available sdma_id */ + bit = __ffs64(dqm->sdma_bitmap); + dqm->sdma_bitmap &= ~(1ULL << bit); + q->sdma_id = bit; + } + q->properties.sdma_engine_id = q->sdma_id % get_num_sdma_engines(dqm); q->properties.sdma_queue_id = q->sdma_id / @@ -1044,9 +1057,19 @@ static int allocate_sdma_queue(struct device_queue_manager *dqm, pr_err("No more XGMI SDMA queue to allocate\n"); return -ENOMEM; } - bit = __ffs64(dqm->xgmi_sdma_bitmap); - dqm->xgmi_sdma_bitmap &= ~(1ULL << bit); - q->sdma_id = bit; + if (restore_sdma_id) { + /* Re-use existing sdma_id */ + if (!(dqm->xgmi_sdma_bitmap & (1ULL << *restore_sdma_id))) { + pr_err("SDMA queue already in use\n"); + return -EBUSY; + } + dqm->xgmi_sdma_bitmap &= ~(1ULL << *restore_sdma_id); + q->sdma_id = *restore_sdma_id; + } else { + bit = __ffs64(dqm->xgmi_sdma_bitmap); + dqm->xgmi_sdma_bitmap &= ~(1ULL << bit); + q->sdma_id = bit; + } /* sdma_engine_id is sdma id including * both PCIe-optimized SDMAs and XGMI- * optimized SDMAs. The calculation below @@ -1269,7 +1292,8 @@ static void destroy_kernel_queue_cpsch(struct device_queue_manager *dqm, } static int create_queue_cpsch(struct device_queue_manager *dqm, struct queue *q, - struct qcm_process_device *qpd) + struct qcm_process_device *qpd, + const struct queue_restore_data *qrd) { int retval; struct mqd_manager *mqd_mgr; @@ -1284,7 +1308,7 @@ static int create_queue_cpsch(struct device_queue_manager *dqm, struct queue *q, if (q->properties.type == KFD_QUEUE_TYPE_SDMA || q->properties.type == KFD_QUEUE_TYPE_SDMA_XGMI) { dqm_lock(dqm); - retval = allocate_sdma_queue(dqm, q); + retval = allocate_sdma_queue(dqm, q, qrd ? &qrd->sdma_id : NULL); dqm_unlock(dqm); if (retval) goto out; diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.h b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.h index 71e2fde56b2b..a5baf50fd6dc 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.h +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.h @@ -86,7 +86,8 @@ struct device_process_node { struct device_queue_manager_ops { int (*create_queue)(struct device_queue_manager *dqm, struct queue *q, - struct qcm_process_device *qpd); + struct qcm_process_device *qpd, + const struct queue_restore_data* qrd); int (*destroy_queue)(struct device_queue_manager *dqm, struct qcm_process_device *qpd, diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h index d21b7eb08a76..bd518340c38c 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h +++ b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h @@ -471,6 +471,7 @@ enum KFD_QUEUE_PRIORITY { struct queue_restore_data { uint32_t qid; + uint32_t sdma_id; }; struct queue_properties { diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c index cb136e13baff..0ca7db288b9f 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c @@ -272,7 +272,7 @@ int pqm_create_queue(struct process_queue_manager *pqm, goto err_create_queue; pqn->q = q; pqn->kq = NULL; - retval = dev->dqm->ops.create_queue(dev->dqm, q, &pdd->qpd); + retval = dev->dqm->ops.create_queue(dev->dqm, q, &pdd->qpd, qrd); print_queue(q); break; @@ -292,7 +292,7 @@ int pqm_create_queue(struct process_queue_manager *pqm, goto err_create_queue; pqn->q = q; pqn->kq = NULL; - retval = dev->dqm->ops.create_queue(dev->dqm, q, &pdd->qpd); + retval = dev->dqm->ops.create_queue(dev->dqm, q, &pdd->qpd, qrd); print_queue(q); break; case KFD_QUEUE_TYPE_DIQ: From patchwork Sat May 1 01:57:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Kuehling X-Patchwork-Id: 12234581 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=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 3F621C433B4 for ; Sat, 1 May 2021 01:58:50 +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 0BCE761407 for ; Sat, 1 May 2021 01:58:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0BCE761407 Authentication-Results: mail.kernel.org; dmarc=fail (p=none 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 B0F5F6F63D; Sat, 1 May 2021 01:58:32 +0000 (UTC) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2042.outbound.protection.outlook.com [40.107.92.42]) by gabe.freedesktop.org (Postfix) with ESMTPS id DED8A6F626; Sat, 1 May 2021 01:58:29 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FYCVL+8yLJX1G6O8abT26ZeO4rmp+MNWKTD2bGVDuFEYa3GegtHVzRuFp65FJQhWBzxCqJoJhi7pZLKDMbayV+8AJV1ujtF7mFv1/IcIeuLOIj21JUwb2H8q6RICFGoUZlMRx/m0bQvIOoFdZaczmBIyaov1yB3vG+/PFBB4PW229T89EoPMBGZX4zVmQ35d1LdpQSuOyFERB7VUj+qWr/shglQt9+nyDdGOcO1Hi1Sm7G42Qx/Ydy9jptJ3TDUcoUj+BBIxi2VyqZs+1Bz4h6xt4bLdhJq+0GxPUpAban0hoHt8OPN8UrUJQLgp6eFO2ia16/oUn7174Uy7hgk3nw== 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=0w+fzE1FBiqHuj/3D7aqa51xmjCPlFbvS8tCRRHLck0=; b=Pw64/fdmcz/MdCVbPaARgG05mQ9ApbSM3XOyXPfjO0GECdWaIrj4LG1Ui632hJ449K55Jdp2bvp/SeI5hTHAqqU1lgf8Y7AohoJNiIwLq38D2mk7ohXc7QSHYm4zElacWSG9Unt8VVJP3T0w+vPhvg/I/wbfEqZm8iM/UDZOiEf1MuwSreHaHBXWFkw35R1nmktRDfuriZWpALdJPhj5jtYB6HBYCWiSbjC1+C4T4qbZrAgMnxOcbi785IHC6b72DjTwLA3dVz5Pw028JLtus/Kv20TBuYf7APcvdumg1MEAYQbLfvkNK36osXEeWWi5HJoZw8UtdHNpI8tPZv8RuQ== 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=0w+fzE1FBiqHuj/3D7aqa51xmjCPlFbvS8tCRRHLck0=; b=0tiX33vkU8b+ie7P42iTDd3BfIlpfljd8xq65JPPbCBewcLUDgyYyyMJtVv4TSjnIpC81P5TgvT/S5REDLiqm9oEqxNQEChmn6uGrVVAUHmfJK2S5cOQSy8vv5Cei7PSu9O4SpSVlbP+YHcPdZ07PritUcdLZmnVmcaG0eESvXU= 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 BL0PR12MB4948.namprd12.prod.outlook.com (2603:10b6:208:1cc::20) by BL0PR12MB4898.namprd12.prod.outlook.com (2603:10b6:208:1c7::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.26; Sat, 1 May 2021 01:58:28 +0000 Received: from BL0PR12MB4948.namprd12.prod.outlook.com ([fe80::70f5:99ed:65a1:c033]) by BL0PR12MB4948.namprd12.prod.outlook.com ([fe80::70f5:99ed:65a1:c033%5]) with mapi id 15.20.4065.027; Sat, 1 May 2021 01:58:28 +0000 From: Felix Kuehling To: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [RFC PATCH 11/17] drm/amdkfd: CRIU restore queue doorbell id Date: Fri, 30 Apr 2021 21:57:46 -0400 Message-Id: <20210501015752.888-12-Felix.Kuehling@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210501015752.888-1-Felix.Kuehling@amd.com> References: <20210501015752.888-1-Felix.Kuehling@amd.com> X-Originating-IP: [165.204.54.211] X-ClientProxiedBy: YT1PR01CA0037.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:2e::6) To BL0PR12MB4948.namprd12.prod.outlook.com (2603:10b6:208:1cc::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (165.204.54.211) by YT1PR01CA0037.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:2e::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.25 via Frontend Transport; Sat, 1 May 2021 01:58:27 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e7c29659-f140-4652-4be4-08d90c449d2f X-MS-TrafficTypeDiagnostic: BL0PR12MB4898: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3044; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WZQXXBOB5+jz4hEMx79ia+qCN2tOIvcRRQ86uYN9mSX1S0g/xpEOy26aBc/3o9NXBjO56bZBdDu7dJ/IconYnOyhg5afTLnGNKqpBwmaffKLV3oPptKhWOHpgOYrRB7AB6uQwmNM4anoA42DvNf+KTbVRqSQqNb+CBjnfF6/iBA/iqJ9QUHXgggD5t3zdGuwVsJVVsW0mMGl7BggAHx41kjBIP9/c6cl3KzpbTMIKHf/V5PssNb1hbOso3E9qwMyj/TYO8UTyYUYvnhV539FdAJKEd6LKvu7ges73mQaeMG3maiE90ZoR/xZjtx35OnBmamWo1juSThdjxsOJD1KxfeusWtXRrKKlt1qrw4oPMVocgoR94jGOJSJptUq+ok9BUxAnItG/++oV237cc2chT00BmlWp8RfjVFO2R7bUvPAr+ERubNQOgR0T5T6PuZK8Xxr4M+d8Ihz9VvwnQFiix3NNeEulhMig+IPzlWh2gpdkNhegrcYrWc0WmNs35dNSvvuBH+7Ap8GaNvarbLLk3E79lHA6XbUsrY/ZaVn3T/JJ2bdH7J38yC75oJdpY+1pl0Q+VHSVEG0FG2ENJPNy4KnaZ+/FvG/0QNW97xBPFLu7NhGZ9nYx8U8P66z8ekLpYQM4RxlLc8uELBIRCfTSlhhlbwTFfRgaeWGKj8G4OpzQL7erVtTtIUKleeNypVp X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BL0PR12MB4948.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(136003)(346002)(39860400002)(396003)(366004)(36756003)(66556008)(66476007)(66946007)(6512007)(86362001)(8936002)(52116002)(478600001)(5660300002)(8676002)(6506007)(6666004)(38350700002)(38100700002)(2616005)(450100002)(4326008)(83380400001)(1076003)(2906002)(26005)(16526019)(6486002)(956004)(316002)(186003)(69590400013); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: Y45Stp9nWXTJA6D78QGrTCCKCjjpN6XsmMXoHiVAKXXcy9IrfjHk13ojPXj7wYNz9eAsaBK5A4h4XNNRdh+tIxxBC3Lwu7qxUrABnYi3heKkTeE05g4TPLu7D+8U9aFX6tds6dZECU6PhLEAUtaUQFUn9z8v34TduWU5qVioeuNHqx1gnmMv/7/uIBqdoCu7BBTny33AeCxlY/gKWsJJT/cYeZpmZhXJ5XbS13S8OaTlVoMKnvMLbCbLwxPfQPWzFiRqCtHr2UvqPS1ZVNNd5yTHGbytvxjzttmtBeUDzEG8//YPneVGiFPNzRYq/vatLkzgX0FMnUwcqaVK341SQjCcrmdJ+KFu3ivt9w3S+uGD5rbNoTKuYjx94M5QIIare8kubjOHfnyIsROswrjghCobeAsbdrxxSD5BdEjFNrhmBMwz3O8FnrUfKQNT1RXoTt5Cklf/ER0KPzJkjGDNa6FnMVbvm9eBabV7ek48uLZGCNg5Ks/RBOq/0Ko6O9YhQEpJNOUUPJbK72waSwvgcVxo4XfXRkJLPrDiOT3vtd6LpO5OVE1KDSxOudAMT56XwLCwGWzCAU2XSOEF2vWOGbIz02fS8dMAiGRATwA7msH0q2khvYlDgp4BMmmHcVitUILbi3AOW5L7YhgKQ0L5QhgXZJXMaZqYcGpOZlEHeFjfudnOPYYWrWoBsMz4WRf9aNDOejjx7YsSFmtcm+KjYqnr7Y0UJXi7nfPNM4odRseS/pOYdmZrdY+85hZfHIjhGjNaNXL1/LlXWW+QRdS0H9ytfEvg26LrV44CleP3P+RpLMYE8p0dD2Jnv6PhH6sPAepkwFLYuM7+p1JGPZNzHWE9D/SgW/I4M4vIMxhsKkWXIkDcuege32aSbZeds8Nbfxv5aJSXbRbKo1SGB4Yl3KTHR6ROEP33WGMfN3kQOWO8Fhrn+Nk9PeYCAMvM43PQ4iZ7PK2Wr29SxGJXIwaZupkfjfz0fRpoEoGbdV/Lp7iqKD19z75pIZn2v3+pkQmXPo4aTSf9/JV98pPck9Mdhc1u2e1GB3A3gI26F4PUjj5ghxk63kImWIUuLOElqiqg8zLqPdDfqZT4CLT9eU+nJPyamDwpJxMds/rgjxcteEawEyKlUnYCVXF9pom2YthY7qvPmkKrlARfsQqf6Z4CRng0x/1W5YNtHWudH9Dpy54AHveXOsN6v59OyuuvRi4N++WJ1zE3CMpcvrhCwbOC9VKJ9Fm+Tjco4vjz+wNyHv2cyvzaqeeTnQIJD7eAWEyNbawMWISGztNpvYX4fIEbamE5A+flCvEpdHsiKEQEgjdpf6m9ZpxbY7slWSnSPUYK X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: e7c29659-f140-4652-4be4-08d90c449d2f X-MS-Exchange-CrossTenant-AuthSource: BL0PR12MB4948.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 May 2021 01:58:28.7731 (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: YfMvrMDwY8K/yZPxz8jUMUccbeGSE768G5rTEFvD+tsEcGD1LFtjQfPAMC5gXICirRd71jX28Gpufh71wBJ6jw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR12MB4898 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: David Yat Sin Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: David Yat Sin When re-creating queues during CRIU restore, restore the queue with the same doorbell id value used during CRIU dump. Signed-off-by: David Yat Sin Change-Id: I6a79de1f8c760d5a9d28e7951740296f2f8796a7 --- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 1 + .../drm/amd/amdkfd/kfd_device_queue_manager.c | 58 +++++++++++++------ drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 1 + 3 files changed, 41 insertions(+), 19 deletions(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c index afcbdae436fa..130ab100abb2 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c @@ -2153,6 +2153,7 @@ int criu_restore_queue(struct kfd_process *p, qrd->qid = q_bucket->q_id; qrd->sdma_id = q_bucket->sdma_id; + qrd->doorbell_id = q_bucket->doorbell_id; ret = pqm_create_queue(&p->pqm, dev, NULL, &qp, &queue_id, qrd, NULL); if (ret) { diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c index cabdfbacce37..56250c0b5ca0 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c @@ -153,7 +153,11 @@ static void decrement_queue_count(struct device_queue_manager *dqm, dqm->active_cp_queue_count--; } -static int allocate_doorbell(struct qcm_process_device *qpd, struct queue *q) +/* + * Allocate a doorbell ID to this queue. + * If doorbell_id is passed in, make sure requested ID is valid then allocate it. + */ +static int allocate_doorbell(struct qcm_process_device *qpd, struct queue *q, uint32_t const *restore_id) { struct kfd_dev *dev = qpd->dqm->dev; @@ -161,6 +165,9 @@ static int allocate_doorbell(struct qcm_process_device *qpd, struct queue *q) /* On pre-SOC15 chips we need to use the queue ID to * preserve the user mode ABI. */ + if (restore_id && *restore_id != q->properties.queue_id) + return -EINVAL; + q->doorbell_id = q->properties.queue_id; } else if (q->properties.type == KFD_QUEUE_TYPE_SDMA || q->properties.type == KFD_QUEUE_TYPE_SDMA_XGMI) { @@ -169,25 +176,38 @@ static int allocate_doorbell(struct qcm_process_device *qpd, struct queue *q) * The doobell index distance between RLC (2*i) and (2*i+1) * for a SDMA engine is 512. */ - uint32_t *idx_offset = - dev->shared_resources.sdma_doorbell_idx; - q->doorbell_id = idx_offset[q->properties.sdma_engine_id] - + (q->properties.sdma_queue_id & 1) - * KFD_QUEUE_DOORBELL_MIRROR_OFFSET - + (q->properties.sdma_queue_id >> 1); + uint32_t *idx_offset = dev->shared_resources.sdma_doorbell_idx; + uint32_t valid_id = idx_offset[q->properties.sdma_engine_id] + + (q->properties.sdma_queue_id & 1) + * KFD_QUEUE_DOORBELL_MIRROR_OFFSET + + (q->properties.sdma_queue_id >> 1); + + if (restore_id && *restore_id != valid_id) + return -EINVAL; + q->doorbell_id = valid_id; } else { - /* For CP queues on SOC15 reserve a free doorbell ID */ - unsigned int found; - - found = find_first_zero_bit(qpd->doorbell_bitmap, - KFD_MAX_NUM_OF_QUEUES_PER_PROCESS); - if (found >= KFD_MAX_NUM_OF_QUEUES_PER_PROCESS) { - pr_debug("No doorbells available"); - return -EBUSY; + /* For CP queues on SOC15 */ + if (restore_id) { + /* make sure that ID is free */ + if (__test_and_set_bit(*restore_id, qpd->doorbell_bitmap)) { + return -EINVAL; + } + + q->doorbell_id = *restore_id; + } else { + /* or reserve a free doorbell ID */ + unsigned int found; + + found = find_first_zero_bit(qpd->doorbell_bitmap, + KFD_MAX_NUM_OF_QUEUES_PER_PROCESS); + if (found >= KFD_MAX_NUM_OF_QUEUES_PER_PROCESS) { + pr_debug("No doorbells available"); + return -EBUSY; + } + set_bit(found, qpd->doorbell_bitmap); + q->doorbell_id = found; } - set_bit(found, qpd->doorbell_bitmap); - q->doorbell_id = found; } q->properties.doorbell_off = @@ -343,7 +363,7 @@ static int create_queue_nocpsch(struct device_queue_manager *dqm, dqm->asic_ops.init_sdma_vm(dqm, q, qpd); } - retval = allocate_doorbell(qpd, q); + retval = allocate_doorbell(qpd, q, qrd ? &qrd->doorbell_id : NULL); if (retval) goto out_deallocate_hqd; @@ -1314,7 +1334,7 @@ static int create_queue_cpsch(struct device_queue_manager *dqm, struct queue *q, goto out; } - retval = allocate_doorbell(qpd, q); + retval = allocate_doorbell(qpd, q, qrd ? &qrd->doorbell_id : NULL); if (retval) goto out_deallocate_sdma_queue; diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h index bd518340c38c..a4a0713ca9a3 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h +++ b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h @@ -472,6 +472,7 @@ enum KFD_QUEUE_PRIORITY { struct queue_restore_data { uint32_t qid; uint32_t sdma_id; + uint32_t doorbell_id; }; struct queue_properties { From patchwork Sat May 1 01:57:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Kuehling X-Patchwork-Id: 12234593 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=-13.7 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, UNWANTED_LANGUAGE_BODY,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 CF02AC43461 for ; Sat, 1 May 2021 01:58:58 +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 98ACD613F7 for ; Sat, 1 May 2021 01:58:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 98ACD613F7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none 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 592FA6F879; Sat, 1 May 2021 01:58:45 +0000 (UTC) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2062.outbound.protection.outlook.com [40.107.223.62]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3CCC16F634; Sat, 1 May 2021 01:58:40 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GFTWFykcYdAclTkXdo3i+EZxFkXQpDaN4dMAA/jAGfpROM7E1STi1gSCqDArfk5tbFGyPrCLFVZajAYnUi0m9PdcRBhvRcm/ODWy/2AAWvinRV80EsjQ2XPM6244div8jxqh/bD0aOwa0DWk1mTqBF8FTdOg3+ONp0mqmuG4BgiQjS2CBMJ0BCFKHkgw+lY3Tldrs+TvU0kYvHdO0r7jgVE3ozpIKiOfGbz3vA8I4zi8HDOw85wPgE2AUahQrSVPaEcY4TABWo4P3OHfOAgFn6wc/XEMgyeks7EZVUHn7KSiTKkqYEBWc+gmeiHnjcQ8qx9XQ3abzcNMevvshwkazg== 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=HPLhzqn3UKv+bXHAQQmMZru015YYYuUsjVAL/MQdfjQ=; b=PRtmpJdE/miTjIVgcTPaofm3TfWlyBRX5Nq9BagvZCSkU+wuACIkPMI4g/ULFWnmzo23mHCpYqYq8Elyo3wsU+49673EVvuJl1dL1kuTZ3O03eIdfDpldndkWlRv620WxsCOJul+uRyRbhLOWfqBSwldh2SgkoSxULDV9qcWmNKVhe2VIvaYdcVtb7nPPA0S7rZJbjJYIaQu1aC+4BnT//WkTRsFjTG4K8tsgiMrr/qUQfxlMY6Scqg+ffQmT1n4qWkP8Ns7O9b3XZCIDVRSIUaVm3hyrG8rpjzt8tv3IKCVT60GZI3BLPhgs0WVOEybIGt9zU438XWvlOEdROWTzw== 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=HPLhzqn3UKv+bXHAQQmMZru015YYYuUsjVAL/MQdfjQ=; b=cGF0i3ngaiY1bTBW8L7C7udYkLvyGwAKdRN9AKTf4mheywGOhqX9cc0M9/uLHHiCx/OndMxkYqr06sf/+kiwxpLX5JQADFflGg/R3+Gn6JC/MkKUglPSg/JIIFdmMucyE0tZRkTTbp0JsIem7BAVSAoF4xRlNPLkNdUDmg/81t4= 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 BL0PR12MB4948.namprd12.prod.outlook.com (2603:10b6:208:1cc::20) by BL0PR12MB4932.namprd12.prod.outlook.com (2603:10b6:208:1c2::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.26; Sat, 1 May 2021 01:58:30 +0000 Received: from BL0PR12MB4948.namprd12.prod.outlook.com ([fe80::70f5:99ed:65a1:c033]) by BL0PR12MB4948.namprd12.prod.outlook.com ([fe80::70f5:99ed:65a1:c033%5]) with mapi id 15.20.4065.027; Sat, 1 May 2021 01:58:30 +0000 From: Felix Kuehling To: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [RFC PATCH 12/17] drm/amdkfd: CRIU restore CU mask for queues Date: Fri, 30 Apr 2021 21:57:47 -0400 Message-Id: <20210501015752.888-13-Felix.Kuehling@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210501015752.888-1-Felix.Kuehling@amd.com> References: <20210501015752.888-1-Felix.Kuehling@amd.com> X-Originating-IP: [165.204.54.211] X-ClientProxiedBy: YT1PR01CA0037.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:2e::6) To BL0PR12MB4948.namprd12.prod.outlook.com (2603:10b6:208:1cc::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (165.204.54.211) by YT1PR01CA0037.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:2e::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.25 via Frontend Transport; Sat, 1 May 2021 01:58:29 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 31454404-629a-4327-6aa1-08d90c449e0d X-MS-TrafficTypeDiagnostic: BL0PR12MB4932: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FM+HtnrkgNzciJJwScopU/ZvR2ZjrKMT6TRc0vQ1cfdZ0u5diRQ3tXnswx8zHTRxhXER6PcDXS8OxkOXzeoBwzf8U7ncPeo8hwcuTEddgD7jhWNtErcfbvtmBIDPpyNLIt38KFY/PcDXl3n/RYsreWAwy1vt6RXPR2Cy0zjKSV/BddrGkHDF8fx+ZiqWEr1tdi/US8PuPRZYGrSPDQ04fj8Fw9G+Je9h2I9toQJ+5vwg/WCHxkovL+zRKWIvJCJnhs/PnGhoNM69FvWNyaLSQixY5Z9YsfakA6nLkLloP2t+OP8WblqX+6Tgjvl2/Ze7fxyXdRU3qQnEWiebEPLdi0XNm8wWuyQNnpQgvms+XytB5p5tGMu8kdsFu2Jmi1yW7zjaXNvIeIP/o9BwW4Gs4zhbwvE/oCuEnTvEsSmxVxDNUZp4j6zYuzHxodIxO4So5aM164nRjoJr5YbDb6ud8tUqlq6HUMGXdVYCpUv6zKjQzYQSQ5eR827xlF/LDlEWoZhR4IrPArZPVjb1eMGMJVCulXnfixpY87w6FoQ2ZvQKmzK1RhF4hm4ivYGrXz9DD2Qw2Mi15ALYjKLKmWWZBsb2l4MsJRZLzvTjNRTv/oUxKNuVoD4E0rfpIOi95e1CAOQwce1i8sav5S86KVqA5Hz6DMxbVgm2hOJjeAnBhaFf5Nvuwg8UpJ+Grjw0Hxn4 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BL0PR12MB4948.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(39860400002)(346002)(136003)(366004)(396003)(6512007)(83380400001)(38350700002)(38100700002)(478600001)(26005)(16526019)(186003)(6486002)(86362001)(4326008)(316002)(2616005)(956004)(450100002)(5660300002)(6666004)(66476007)(66556008)(52116002)(2906002)(6506007)(66946007)(8676002)(36756003)(8936002)(1076003)(69590400013); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: Lx3zXY2J2kkNavKaGF43kEb+YaPfChPbu8koBLyd6dndAcEHXWuoBupgHg1/H/xTJ1pcphxHWlSIkYrN6BuzLOp41wCynnfotCPB5jGQsR8Q93FsH2crIhzHygDl9JbnUIaIzxF4HJPLtZ4RlAF+/Z8FydxtoHJXFUouO+KA5JYwNpS7B+UO7dMpkY+YZd1uFU/vb/thWha66wM3NVNjvZgwNhbJ1UzY/lL0baOX4P4VrYjfu3F5BGIXx6UOKHU0u7h0eoQXG5pvatNaWJPTBzDBWs1lut4vQuaZZgGeKXa+AuiDkjH2YyINSg3jHNXu/offnsEKUy4ywWi11dvSPaf5c6RuRQzb8nKNPy3YrW+wh6lCWwlidV/Ed8YnDVaCJSHmmzhOAH57mE5GwoKhan6xk0IpT/rsR3HOpZfi/6qMb2Vtf8QvR9pICVOJfyCv/LIr+oCOZAeLdPJ4rpxeDxrIKqCdJ7AJlWTdC8PCVsFqCzvQIIC3IS2OSnHfaHjaqqbGlm3u8BtlCndoS+7wObonsHhZkn1A+nhNySFPeMvuhtyA02vKJV8t3AcEhTg4r2snfmiCKb3Y2OA5wyoJkQlr1GSMXLbJXMVhKTRZwV5haAO0Vj3ICnY3fcfPNZHI33OCacy2qbWRi6BOuiY9JO6ULocc8+hhsD7Cbcag+YcYq6FWC6a0io43uqbQrSUpcilYo1bUE2D+B/PFv7zfdrmhepb87Onf+LB7I4+cCqVs6PYnxuGB3N3oJ6n+b2HEwid6MOCADcXmXnQuiS+odXc8b0x+UEQENWFxY1QIOG4mrdSsUzcxdj914XBpug6q5luzMfzIlvp4YmziqA0CfP7yunSw0tpJBylCCPQmGUWS1VJhkX5lOF+bsGZgtQVtVXihlSBb7OEVFYns+79r4TQ2flmF+KkyOhf+DPCWVh05HB9mdt0Bu9E/jn/lviCreE1nGR6Hdw6Pqk7QEjYjXlzlWCl/H8PiFpfOEjaSseaZG7Z2alV2sYB1zMZPOLgk76qDtIsPqt48/wIebVSpraUFGmlkHMX2NGwnNNW+J7t3hDEA8JGpTnESzZuD331vZsjch6Cj+yKa0XlPNACYtfd3SN97coTlrIKHj1zlUZfHfZxZ93VlCdONm1pXborHxoW81lFshhyIBCNgT8dXh0czl9G12NApXaDIgUNQKBbEu1WQjmJMBdK8ROv2JCFbilOta4RCNEVTx2uc4DnxrKJqG6NY9o5RJPlP32HY5DzeR5AzkUVdl7Vqti3mg66iM3fcZ+YaeWwFHNS9uHBsZqF06PcsF3W8cKkKRb54hfafoSNrH2kd1233PU5X1izj X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 31454404-629a-4327-6aa1-08d90c449e0d X-MS-Exchange-CrossTenant-AuthSource: BL0PR12MB4948.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 May 2021 01:58:30.2438 (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: 2wHlbFtZrgIdLo/UcQws4H7USDiccQfaQTzNKZLqrzz90GXLSZcbWZtRdlHH8STDBmUZhT4QcmVr/Kf/if8hMQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR12MB4932 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: David Yat Sin Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: David Yat Sin When re-creating queues during CRIU restore, restore the queue with the same CU mask value used during CRIU dump. Signed-off-by: David Yat Sin Change-Id: I1822fa2488f90365dfe7a3c5971a2ed6c0046b4a --- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 160 +++++++++++++++++++++-- drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 3 + 2 files changed, 154 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c index 130ab100abb2..1d2c2d986a44 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c @@ -1890,9 +1890,21 @@ static int kfd_devinfo_restore(struct kfd_process *p, struct kfd_criu_devinfo_bu } return 0; } -static void criu_dump_queue(struct kfd_process_device *pdd, + +static int get_queue_data_sizes(struct kfd_process_device *pdd, + struct queue *q, + uint32_t *cu_mask_size) +{ + int ret = 0; + + *cu_mask_size = sizeof(uint32_t) * (q->properties.cu_mask_count / 32); + return ret; +} + +static int criu_dump_queue(struct kfd_process_device *pdd, struct queue *q, - struct kfd_criu_q_bucket *q_bucket) + struct kfd_criu_q_bucket *q_bucket, + struct queue_restore_data *qrd) { q_bucket->gpu_id = pdd->dev->id; q_bucket->type = q->properties.type; @@ -1920,18 +1932,30 @@ static void criu_dump_queue(struct kfd_process_device *pdd, q->properties.ctx_save_restore_area_size; q_bucket->ctl_stack_size = q->properties.ctl_stack_size; + if (qrd->cu_mask_size) + memcpy(qrd->cu_mask, q->properties.cu_mask, qrd->cu_mask_size); + + q_bucket->cu_mask_size = qrd->cu_mask_size; + return 0; } static int criu_dump_queues_device(struct kfd_process_device *pdd, unsigned *q_index, unsigned int max_num_queues, - struct kfd_criu_q_bucket *user_buckets) + struct kfd_criu_q_bucket *user_buckets, + uint8_t *queues_data, + uint32_t *queues_data_offset, + uint32_t queues_data_size) { struct queue *q; + struct queue_restore_data qrd; struct kfd_criu_q_bucket q_bucket; + uint8_t *data_ptr = NULL; + unsigned int data_ptr_size = 0; int ret = 0; list_for_each_entry(q, &pdd->qpd.queues_list, list) { + unsigned int q_data_size; if (q->properties.type != KFD_QUEUE_TYPE_COMPUTE && q->properties.type != KFD_QUEUE_TYPE_SDMA && q->properties.type != KFD_QUEUE_TYPE_SDMA_XGMI) { @@ -1949,7 +1973,49 @@ static int criu_dump_queues_device(struct kfd_process_device *pdd, } memset(&q_bucket, 0, sizeof(q_bucket)); - criu_dump_queue(pdd, q, &q_bucket); + memset(&qrd, 0, sizeof(qrd)); + + ret = get_queue_data_sizes(pdd, q, &qrd.cu_mask_size); + if (ret) { + pr_err("Failed to get queue dump info (%d)\n", ret); + ret = -EFAULT; + break; + } + + q_data_size = qrd.cu_mask_size; + + /* Increase local buffer space if needed */ + if (data_ptr_size < q_data_size) { + if (data_ptr) + kfree(data_ptr); + + data_ptr = (uint8_t*)kzalloc(q_data_size, GFP_KERNEL); + if (!data_ptr) { + ret = -ENOMEM; + break; + } + data_ptr_size = q_data_size; + } + + qrd.cu_mask = data_ptr; + ret = criu_dump_queue(pdd, q, &q_bucket, &qrd); + if (ret) + break; + + if (*queues_data_offset + q_data_size > queues_data_size) { + pr_err("Required memory exceeds user provided\n"); + ret = -ENOSPC; + break; + } + ret = copy_to_user((void __user *) (queues_data + *queues_data_offset), + data_ptr, q_data_size); + if (ret) { + ret = -EFAULT; + break; + } + q_bucket.queues_data_offset = *queues_data_offset; + *queues_data_offset += q_data_size; + ret = copy_to_user((void __user *)&user_buckets[*q_index], &q_bucket, sizeof(q_bucket)); if (ret) { @@ -1959,6 +2025,10 @@ static int criu_dump_queues_device(struct kfd_process_device *pdd, } *q_index = *q_index + 1; } + + if (data_ptr) + kfree(data_ptr); + return ret; } @@ -1976,6 +2046,8 @@ static int kfd_ioctl_criu_dumper(struct file *filep, struct kfd_criu_q_bucket *user_buckets = (struct kfd_criu_q_bucket*) args->kfd_criu_q_buckets_ptr; + uint8_t *queues_data = (uint8_t*)args->queues_data_ptr; + uint32_t queues_data_offset = 0; pr_info("Inside %s\n",__func__); @@ -2076,7 +2148,10 @@ static int kfd_ioctl_criu_dumper(struct file *filep, } ret = criu_dump_queues_device(pdd, &q_index, - args->num_of_queues, user_buckets); + args->num_of_queues, user_buckets, + queues_data, &queues_data_offset, + args->queues_data_size); + if (ret) goto err_unlock; } @@ -2098,8 +2173,9 @@ static int kfd_ioctl_criu_dumper(struct file *filep, return ret; } -static void set_queue_properties_from_criu(struct queue_properties *qp, - struct kfd_criu_q_bucket *q_bucket) +static int set_queue_properties_from_criu(struct queue_properties *qp, + struct kfd_criu_q_bucket *q_bucket, + struct queue_restore_data *qrd) { qp->is_interop = false; qp->is_gws = q_bucket->is_gws; @@ -2116,6 +2192,19 @@ static void set_queue_properties_from_criu(struct queue_properties *qp, qp->ctl_stack_size = q_bucket->ctl_stack_size; qp->type = q_bucket->type; qp->format = q_bucket->format; + + if (qrd->cu_mask_size) { + qp->cu_mask = kzalloc(qrd->cu_mask_size, GFP_KERNEL); + if (!qp->cu_mask) { + pr_err("Failed to allocate memory for CU mask\n"); + return -ENOMEM; + } + + memcpy(qp->cu_mask, qrd->cu_mask, qrd->cu_mask_size); + qp->cu_mask_count = (qrd->cu_mask_size / sizeof(uint32_t)) * 32; + } + + return 0; } /* criu_restore_queue runs with the process mutex locked */ @@ -2148,7 +2237,10 @@ int criu_restore_queue(struct kfd_process *p, q_bucket->q_address); memset(&qp, 0, sizeof(qp)); - set_queue_properties_from_criu(&qp, q_bucket); + ret = set_queue_properties_from_criu(&qp, q_bucket, qrd); + if (ret) + goto err_create_queue; + print_queue_properties(&qp); qrd->qid = q_bucket->q_id; @@ -2158,12 +2250,18 @@ int criu_restore_queue(struct kfd_process *p, ret = pqm_create_queue(&p->pqm, dev, NULL, &qp, &queue_id, qrd, NULL); if (ret) { pr_err("Failed to create new queue err:%d\n", ret); - return -EINVAL; + ret = -EINVAL; + goto err_create_queue; } pr_debug("Queue id %d was restored successfully\n", queue_id); return 0; +err_create_queue: + if (qp.cu_mask) + kfree(qp.cu_mask); + + return ret; } /* criu_restore_queues runs with the process mutex locked */ @@ -2176,6 +2274,11 @@ static int criu_restore_queues(struct kfd_process *p, int ret; struct kfd_criu_q_bucket *user_buckets = (struct kfd_criu_q_bucket*) args->kfd_criu_q_buckets_ptr; + + uint8_t *queues_data = (uint8_t*)args->queues_data_ptr; + uint8_t *data_ptr = NULL; + uint32_t data_ptr_size = 0; + /* * This process will not have any queues at this point, but we are * setting all the dqm's for this process to evicted state. @@ -2185,6 +2288,7 @@ static int criu_restore_queues(struct kfd_process *p, for (i = 0; i < args->num_of_queues; i++) { struct kfd_criu_q_bucket q_bucket; struct queue_restore_data qrd; + uint32_t q_data_size; memset(&qrd, 0, sizeof(qrd)); @@ -2212,12 +2316,42 @@ static int criu_restore_queues(struct kfd_process *p, ret = -EFAULT; return ret; } + + q_data_size = q_bucket.cu_mask_size; + + /* Increase local buffer space if needed */ + if (q_data_size > data_ptr_size) { + if (data_ptr) + kfree(data_ptr); + + data_ptr = (uint8_t*)kzalloc(q_data_size, GFP_KERNEL); + if (!data_ptr) { + ret = -ENOMEM; + break; + } + data_ptr_size = q_data_size; + } + + ret = copy_from_user(data_ptr, + (void __user *) queues_data + q_bucket.queues_data_offset, + q_data_size); + if (ret) { + ret = -EFAULT; + break; + } + + qrd.cu_mask_size = q_bucket.cu_mask_size; + qrd.cu_mask = data_ptr; + ret = criu_restore_queue(p, dev, pdd, &q_bucket, &qrd); if (ret) { pr_err("Failed to restore queue (%d)\n", ret); break; } } + + if (data_ptr) + kfree(data_ptr); return ret; } @@ -2507,6 +2641,7 @@ static int kfd_ioctl_criu_helper(struct file *filep, struct kfd_process *p, void *data) { struct kfd_ioctl_criu_helper_args *args = data; + u32 queues_data_size = 0; struct kgd_mem *kgd_mem; struct queue *q; u64 num_of_bos = 0; @@ -2544,6 +2679,12 @@ static int kfd_ioctl_criu_helper(struct file *filep, q->properties.type == KFD_QUEUE_TYPE_SDMA || q->properties.type == KFD_QUEUE_TYPE_SDMA_XGMI) { + u32 cu_mask_size = 0; + ret = get_queue_data_sizes(pdd, q, &cu_mask_size); + if (ret) + goto err_unlock; + + queues_data_size += cu_mask_size; q_index++; } else { pr_err("Unsupported queue type (%d)\n", q->properties.type); @@ -2558,6 +2699,7 @@ static int kfd_ioctl_criu_helper(struct file *filep, args->num_of_devices = p->n_pdds; args->num_of_bos = num_of_bos; args->num_of_queues = q_index; + args->queues_data_size = queues_data_size; dev_dbg(kfd_device, "Num of bos = %llu\n", num_of_bos); err_unlock: diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h index a4a0713ca9a3..55180a6fe102 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h +++ b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h @@ -473,6 +473,9 @@ struct queue_restore_data { uint32_t qid; uint32_t sdma_id; uint32_t doorbell_id; + + void *cu_mask; + uint32_t cu_mask_size; }; struct queue_properties { From patchwork Sat May 1 01:57:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Kuehling X-Patchwork-Id: 12234585 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=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 A70B0C43460 for ; Sat, 1 May 2021 01:58:53 +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 5EAF6613F7 for ; Sat, 1 May 2021 01:58:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5EAF6613F7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none 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 9F5806F642; Sat, 1 May 2021 01:58:42 +0000 (UTC) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2078.outbound.protection.outlook.com [40.107.223.78]) by gabe.freedesktop.org (Postfix) with ESMTPS id 470B26F63E; Sat, 1 May 2021 01:58:40 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iZRrRUQywmBHJMCpgdM/ai5jM1hQmRo6JKS6dEujs/eCiHLaRBASsW30gQlhWxjJ2FSMVpbiBwoKWhTyFH6XVwJz5bzU4NVpA8MIwXZo8X/6pbYKTl3up/l3h8k0bY5n1slSdTlCjMfDMPGV2nsgt9QdI7COKy+Cp0rIJwqwfb0ob0LG3KsX6NKKdN/2qFogfw4naXIkJWTm+o3BPtksyHRbuFy7J+pm+Jf+74KfwazE6oAgXrzUOK56XiZkFI7CPW6O+awRZpuOnm3sohGAsPrkc0+j7pcq4E0ODgV+Do2LOSzma1s7Bfa2Y1WrspMJXBYxAaQtefcbUW7c8G3ZYQ== 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=BC4b4aKMFDUO8UTDtKfjT5HBi/rudmrTXTcGl+Ef3ec=; b=K/nqr/HtBN2NaBGjQCjISWDzBiAwhs88NMIefLGQGth+kRilNfOQYouGjJD/QvbVVNJ66+RRn3s8wjG70iZ99MjsytJxzrEEDyOXTR7ZFe8A4sJ9PBvNz/VgW1cXXED3v644Yzz+Zad13Sp3mE0/HEdH+sBt+o8ZUR63YBCVUz27CnR0ostnwexgl1cxcljZ2f7sl0qFgwFhJjWlbFlkYSNnj11xHxTln5G+eNYPvG9bHgJFOAVVypA65eqHlYmpp1u9TrdksnJsigDe25bPmyXIhg8Z8LfLjpbEEnDlLanzyccgyc3VXi+cEvOyrRuZ3lZbmFGMeXoquBaPC1qmoQ== 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=BC4b4aKMFDUO8UTDtKfjT5HBi/rudmrTXTcGl+Ef3ec=; b=BqxDoGU54oqVZ5VVhabgEIm+Xc0v3lhE6z8V5jUsvAckFN+dGXca3Zf49lqU6YMzYjio9wVNlaVT59KeYo32DCbyUdue8UekhK8zWpngp9dk47z7prG/SK6d84mP8kpmEPZO/5+HUV0iMcQ6MRUHfp7OeJ2fWw/mkl9LYA7RbuI= 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 BL0PR12MB4948.namprd12.prod.outlook.com (2603:10b6:208:1cc::20) by BL0PR12MB4932.namprd12.prod.outlook.com (2603:10b6:208:1c2::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.26; Sat, 1 May 2021 01:58:31 +0000 Received: from BL0PR12MB4948.namprd12.prod.outlook.com ([fe80::70f5:99ed:65a1:c033]) by BL0PR12MB4948.namprd12.prod.outlook.com ([fe80::70f5:99ed:65a1:c033%5]) with mapi id 15.20.4065.027; Sat, 1 May 2021 01:58:31 +0000 From: Felix Kuehling To: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [RFC PATCH 13/17] drm/amdkfd: CRIU dump and restore queue mqds Date: Fri, 30 Apr 2021 21:57:48 -0400 Message-Id: <20210501015752.888-14-Felix.Kuehling@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210501015752.888-1-Felix.Kuehling@amd.com> References: <20210501015752.888-1-Felix.Kuehling@amd.com> X-Originating-IP: [165.204.54.211] X-ClientProxiedBy: YT1PR01CA0037.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:2e::6) To BL0PR12MB4948.namprd12.prod.outlook.com (2603:10b6:208:1cc::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (165.204.54.211) by YT1PR01CA0037.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:2e::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.25 via Frontend Transport; Sat, 1 May 2021 01:58:30 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ce7497a3-c5c5-4439-e87c-08d90c449ec1 X-MS-TrafficTypeDiagnostic: BL0PR12MB4932: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:418; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9vr69etK0Mc0uETSukEJQrf9qn07um3MlynShY9U/inYg3TO5JRYVFCrlLagAbxUsrC3wZVYpJj/lFy7p3ZpyIddvEXkdaBTgpAETgI9yBVo9T1tfkgl3mYHoK+6DpNtUR2Zp451rahLAdiDZm99NzJuGxuOhrWLmgXi23u2sXc4WlLp8VN30qf+z/4iZorS5jke9xGAU5b4ShnYrxsiInLwOZRqt0YS7hpP9Edev311eyVvNZX+nbAJ+fEAf935TCCOy4osRtTg/AzeaUBS7g5GAn5qGvp6coyjB5BYUVRAz0Wtx3ZbxJnBoenvXsna6/AOhUbzM9JUp0+C/EQeRnlGXjW86zchJsE0xeWlGnRQaf8hTdfKglHm0vjrbVl4w2v/0df9haiTbVXSU8dIICHV5v7PWCAH6zSJA3q9elYEiEqmoySh6u7JH/781S6P7y7L8RF/pVIwH+/+GexyURl/tT4ZQkvIgoSi6z7Zxy6DS8JuJyF5On/SplUjxb3EnW+2vILMGT0YpPC9U2qv2W5v0Eh+MyVUQHUlz4SgcEQLmJ1AoZm1CoSgGy1ZOhpxZFbGKY68PNRv3hkSDOQSpGfk2Un617xpcWK6/fgftLNTXiRCy2bhSU49obGGLqe6nPlSr4g26kWLO2eykF9cR1ClGslZSmEI89LdDv6IyfLsRjGFN1TQDJ1GpIVqyk8CfhuBNvRcI/bbH5Ng999O8Dz78JihHGKrdMooybkdttU= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BL0PR12MB4948.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(39860400002)(346002)(136003)(366004)(396003)(6512007)(83380400001)(38350700002)(38100700002)(478600001)(26005)(16526019)(186003)(6486002)(86362001)(4326008)(316002)(2616005)(956004)(450100002)(5660300002)(6666004)(66476007)(66556008)(52116002)(2906002)(6506007)(66946007)(8676002)(36756003)(8936002)(30864003)(1076003)(69590400013)(309714004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: VzqzJXSuT/2BNKZ9j7RuGsuSEIEOtOeUjhF32eOJDzGxsbcELFfgJLQ8xE5loxaSWCIIOvrWW6Xu6QuhcT4S6blw9xQAmD9xqII9DNSv6o+kEFkMTp28kKwcRj/yGCVE8BbgwDZAhLpLfeptipqcVW7TqA7CJsip8doLJgIZatpX42eN/bCWItOmQqbKXG6jo3IdfGFCnIqNgyTVBdgDYIbWvDk9kW4QOilr/hyHq7FgNDyzMBSN5wrG0h9PWwRjZTl28lyFitbRhRMbUznB3/NqjhObgtkG4MWZR6XKfCNVAVG5L8V0XLimPEd/0YS+tzgp45cHhk89PSwkmZTXwB7JLxQ/NNSOOXwdiRQXkwWOuoV9oA1kIQIVN/XYkHqMilavmoPoCitrlcv8CkCeFxflhkjRktmTa8zjytaJh/JvPtXat1foP2PxsphGqkz0WkB0sWQhi392suDmNcfTmvL2kFuOhd/yR75Rd9hjj8JGDudJnIqjBGDR7ij3x79ITV2xvPZ47XlxzUAVTIuoerO2qkvPIJ645ckmlgzBnoGfOlbl4VKbzM6f8fUjMON2PIjSvq3Moe5FyxgzLH3DnmZZMzHZ2iXjPrk1Nm+9GJXGFc1f8ob+RjnAueedudYXuD+TQhHf/PGKsIUb5NLJUomct/eMsGPb222BO+kiohxASWFCXK1ag9Aa3dB2LG7Gkaw1CrgMtHuTXW6jGMerYm+kc86PnYlLQ4Fxji4xyycpUwt5KrT5PcJ+t6aF8jEOa2KdSNJ+KcNmaQl3ARcMstNxt0o9zqBoyEE6tK9eEFJU/+sLo0L1A/l6UwjTvZvYZEJkHusXNMgQR2IswI5Wq0fxYAx5dGs0YtsKvMMvmWHI4NzhpAfAuPf4B7HmxHRMFeOwkSBYfurUpSs9qJA5vh8Qj0OeWPP1+px10hrE8KD4LJNYmXUchoMgWEy71taJ6VbAI0pBTGbf3MKhBDWfoBCqUmvN/H5T0PmNmQ9GTMVAACf9GgKnznVeX3Cm1rNy6nnfv0uyUdM/TPqaX7u5wGlKbjsDgpIpbQ7VuszQvNYQFacLk9vHTTfIihHQMB4rx5NpkG7pjjC/r/ZtVv8sTIls1iHqAuDBvLqamYzOxLBr8fGUIcYQB8iQNgokhWrkM1eLO7hQQW5D9GkNSyUxM29iGSpQjCuRCJJB/41xHZFY8lrHg1AikEmQ6RHJGYPvv/VfbogoYPt5wG7ywdYQnAs1cFWRgYiFCCr0JZhg//JZlOxbVSuikfEBf0Gymg2sHiqlJYyES6q3bNSCn4vXjSFcwws5QSC+ewAsohNxCLL+Fzqtg52wa2nO8NhVPBlk X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: ce7497a3-c5c5-4439-e87c-08d90c449ec1 X-MS-Exchange-CrossTenant-AuthSource: BL0PR12MB4948.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 May 2021 01:58:31.2922 (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: hyNW31BqImBlX6MwBbpTqmkVo5pPOxahDcjfV4IkPdKtibCxA+Iwt5nEURJAneAHjMkMHAzKPjBzbmv/JbE7bQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR12MB4932 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: David Yat Sin Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: David Yat Sin Dump contents of queue MQD's on CRIU dump and restore them during CRIU restore. Signed-off-by: David Yat Sin Change-Id: If54f892fb6cb8a5bde8a993891dad0dbb997c239 --- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 35 ++++++++-- .../drm/amd/amdkfd/kfd_device_queue_manager.c | 64 +++++++++++++++-- .../drm/amd/amdkfd/kfd_device_queue_manager.h | 8 +++ drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.h | 8 +++ .../gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c | 66 ++++++++++++++++++ .../gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c | 67 ++++++++++++++++++ .../gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c | 68 +++++++++++++++++++ .../gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c | 67 ++++++++++++++++++ drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 8 +++ .../amd/amdkfd/kfd_process_queue_manager.c | 42 ++++++++++++ 10 files changed, 422 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c index 1d2c2d986a44..b7f3aa759c17 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c @@ -1893,11 +1893,18 @@ static int kfd_devinfo_restore(struct kfd_process *p, struct kfd_criu_devinfo_bu static int get_queue_data_sizes(struct kfd_process_device *pdd, struct queue *q, - uint32_t *cu_mask_size) + uint32_t *cu_mask_size, + uint32_t *mqd_size) { int ret = 0; *cu_mask_size = sizeof(uint32_t) * (q->properties.cu_mask_count / 32); + + ret = pqm_get_queue_dump_info(&pdd->process->pqm, q->properties.queue_id, mqd_size); + if (ret) { + pr_err("Failed to get queue dump info (%d)\n", ret); + return ret; + } return ret; } @@ -1906,6 +1913,8 @@ static int criu_dump_queue(struct kfd_process_device *pdd, struct kfd_criu_q_bucket *q_bucket, struct queue_restore_data *qrd) { + int ret = 0; + q_bucket->gpu_id = pdd->dev->id; q_bucket->type = q->properties.type; q_bucket->format = q->properties.format; @@ -1935,8 +1944,15 @@ static int criu_dump_queue(struct kfd_process_device *pdd, if (qrd->cu_mask_size) memcpy(qrd->cu_mask, q->properties.cu_mask, qrd->cu_mask_size); + ret = pqm_dump_mqd(&pdd->process->pqm, q->properties.queue_id, qrd); + if (ret) { + pr_err("Failed dump queue_mqd (%d)\n", ret); + return ret; + } + q_bucket->cu_mask_size = qrd->cu_mask_size; - return 0; + q_bucket->mqd_size = qrd->mqd_size; + return ret; } static int criu_dump_queues_device(struct kfd_process_device *pdd, @@ -1975,14 +1991,14 @@ static int criu_dump_queues_device(struct kfd_process_device *pdd, memset(&q_bucket, 0, sizeof(q_bucket)); memset(&qrd, 0, sizeof(qrd)); - ret = get_queue_data_sizes(pdd, q, &qrd.cu_mask_size); + ret = get_queue_data_sizes(pdd, q, &qrd.cu_mask_size, &qrd.mqd_size); if (ret) { pr_err("Failed to get queue dump info (%d)\n", ret); ret = -EFAULT; break; } - q_data_size = qrd.cu_mask_size; + q_data_size = qrd.cu_mask_size + qrd.mqd_size; /* Increase local buffer space if needed */ if (data_ptr_size < q_data_size) { @@ -1998,6 +2014,7 @@ static int criu_dump_queues_device(struct kfd_process_device *pdd, } qrd.cu_mask = data_ptr; + qrd.mqd = data_ptr + qrd.cu_mask_size; ret = criu_dump_queue(pdd, q, &q_bucket, &qrd); if (ret) break; @@ -2317,7 +2334,7 @@ static int criu_restore_queues(struct kfd_process *p, return ret; } - q_data_size = q_bucket.cu_mask_size; + q_data_size = q_bucket.cu_mask_size + q_bucket.mqd_size; /* Increase local buffer space if needed */ if (q_data_size > data_ptr_size) { @@ -2343,6 +2360,9 @@ static int criu_restore_queues(struct kfd_process *p, qrd.cu_mask_size = q_bucket.cu_mask_size; qrd.cu_mask = data_ptr; + qrd.mqd_size = q_bucket.mqd_size; + qrd.mqd = data_ptr + qrd.cu_mask_size; + ret = criu_restore_queue(p, dev, pdd, &q_bucket, &qrd); if (ret) { pr_err("Failed to restore queue (%d)\n", ret); @@ -2680,11 +2700,12 @@ static int kfd_ioctl_criu_helper(struct file *filep, q->properties.type == KFD_QUEUE_TYPE_SDMA_XGMI) { u32 cu_mask_size = 0; - ret = get_queue_data_sizes(pdd, q, &cu_mask_size); + u32 mqd_size = 0; + ret = get_queue_data_sizes(pdd, q, &cu_mask_size, &mqd_size); if (ret) goto err_unlock; - queues_data_size += cu_mask_size; + queues_data_size += cu_mask_size + mqd_size; q_index++; } else { pr_err("Unsupported queue type (%d)\n", q->properties.type); diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c index 56250c0b5ca0..ee34229a41b0 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c @@ -376,8 +376,14 @@ static int create_queue_nocpsch(struct device_queue_manager *dqm, retval = -ENOMEM; goto out_deallocate_doorbell; } - mqd_mgr->init_mqd(mqd_mgr, &q->mqd, q->mqd_mem_obj, - &q->gart_mqd_addr, &q->properties); + + if (qrd) + mqd_mgr->restore_mqd(mqd_mgr, &q->mqd, q->mqd_mem_obj, + &q->gart_mqd_addr, &q->properties, qrd); + else + mqd_mgr->init_mqd(mqd_mgr, &q->mqd, q->mqd_mem_obj, + &q->gart_mqd_addr, &q->properties); + if (q->properties.is_active) { if (!dqm->sched_running) { WARN_ONCE(1, "Load non-HWS mqd while stopped\n"); @@ -1359,8 +1365,13 @@ static int create_queue_cpsch(struct device_queue_manager *dqm, struct queue *q, * updates the is_evicted flag but is a no-op otherwise. */ q->properties.is_evicted = !!qpd->evicted; - mqd_mgr->init_mqd(mqd_mgr, &q->mqd, q->mqd_mem_obj, - &q->gart_mqd_addr, &q->properties); + + if (qrd) + mqd_mgr->restore_mqd(mqd_mgr, &q->mqd, q->mqd_mem_obj, + &q->gart_mqd_addr, &q->properties, qrd); + else + mqd_mgr->init_mqd(mqd_mgr, &q->mqd, q->mqd_mem_obj, + &q->gart_mqd_addr, &q->properties); list_add(&q->list, &qpd->queues_list); qpd->queue_count++; @@ -1743,6 +1754,47 @@ static int get_wave_state(struct device_queue_manager *dqm, return r; } +static void get_queue_dump_info(struct device_queue_manager *dqm, + const struct queue *q, + u32 *mqd_size) +{ + struct mqd_manager *mqd_mgr; + enum KFD_MQD_TYPE mqd_type = + get_mqd_type_from_queue_type(q->properties.type); + + mqd_mgr = dqm->mqd_mgrs[mqd_type]; + *mqd_size = mqd_mgr->mqd_size; +} + +static int dump_mqd(struct device_queue_manager *dqm, + const struct queue *q, + struct queue_restore_data *qrd) +{ + struct mqd_manager *mqd_mgr; + int r = 0; + enum KFD_MQD_TYPE mqd_type = + get_mqd_type_from_queue_type(q->properties.type); + + dqm_lock(dqm); + + if (q->properties.is_active || !q->device->cwsr_enabled) { + r = -EINVAL; + goto dqm_unlock; + } + + mqd_mgr = dqm->mqd_mgrs[mqd_type]; + if (!mqd_mgr->dump_mqd) { + r = -ENOTSUPP; + goto dqm_unlock; + } + + mqd_mgr->dump_mqd(mqd_mgr, q->mqd, qrd); + +dqm_unlock: + dqm_unlock(dqm); + return r; +} + static int process_termination_cpsch(struct device_queue_manager *dqm, struct qcm_process_device *qpd) { @@ -1917,6 +1969,8 @@ struct device_queue_manager *device_queue_manager_init(struct kfd_dev *dev) dqm->ops.evict_process_queues = evict_process_queues_cpsch; dqm->ops.restore_process_queues = restore_process_queues_cpsch; dqm->ops.get_wave_state = get_wave_state; + dqm->ops.get_queue_dump_info = get_queue_dump_info; + dqm->ops.dump_mqd = dump_mqd; break; case KFD_SCHED_POLICY_NO_HWS: /* initialize dqm for no cp scheduling */ @@ -1936,6 +1990,8 @@ struct device_queue_manager *device_queue_manager_init(struct kfd_dev *dev) dqm->ops.restore_process_queues = restore_process_queues_nocpsch; dqm->ops.get_wave_state = get_wave_state; + dqm->ops.get_queue_dump_info = get_queue_dump_info; + dqm->ops.dump_mqd = dump_mqd; break; default: pr_err("Invalid scheduling policy %d\n", dqm->sched_policy); diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.h b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.h index a5baf50fd6dc..27952e33a404 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.h +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.h @@ -135,6 +135,14 @@ struct device_queue_manager_ops { void __user *ctl_stack, u32 *ctl_stack_used_size, u32 *save_area_used_size); + + void (*get_queue_dump_info)(struct device_queue_manager *dqm, + const struct queue *q, + u32 *mqd_size); + + int (*dump_mqd)(struct device_queue_manager *dqm, + const struct queue *q, + struct queue_restore_data *qrd); }; struct device_queue_manager_asic_ops { diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.h b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.h index b5e2ea7550d4..82da00bc71aa 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.h +++ b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.h @@ -98,6 +98,14 @@ struct mqd_manager { u32 *ctl_stack_used_size, u32 *save_area_used_size); + void (*dump_mqd)(struct mqd_manager *mm, void *mqd, + struct queue_restore_data *qrd); + + void (*restore_mqd)(struct mqd_manager *mm, void **mqd, + struct kfd_mem_obj *mqd_mem_obj, uint64_t *gart_addr, + struct queue_properties *p, + const struct queue_restore_data *qrd); + #if defined(CONFIG_DEBUG_FS) int (*debugfs_show_mqd)(struct seq_file *m, void *data); #endif diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c index 064914e1e8d6..3f59466a5104 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c @@ -275,6 +275,68 @@ static int destroy_mqd(struct mqd_manager *mm, void *mqd, pipe_id, queue_id); } +static void dump_mqd(struct mqd_manager *mm, void *mqd, + struct queue_restore_data *qrd) +{ + struct cik_mqd *m; + m = get_mqd(mqd); + + memcpy(qrd->mqd, m, sizeof(struct cik_mqd)); +} + +static void restore_mqd(struct mqd_manager *mm, void **mqd, + struct kfd_mem_obj *mqd_mem_obj, uint64_t *gart_addr, + struct queue_properties *qp, + const struct queue_restore_data *qrd) +{ + uint64_t addr; + struct cik_mqd *m; + m = (struct cik_mqd *) mqd_mem_obj->cpu_ptr; + addr = mqd_mem_obj->gpu_addr; + + memcpy(m, qrd->mqd, sizeof(*m)); + + *mqd = m; + if (gart_addr) + *gart_addr = addr; + + m->cp_hqd_pq_doorbell_control = DOORBELL_OFFSET(qp->doorbell_off); + + pr_debug("cp_hqd_pq_doorbell_control 0x%x\n", + m->cp_hqd_pq_doorbell_control); + + qp->is_active = 0; +} + +static void dump_mqd_sdma(struct mqd_manager *mm, void *mqd, + struct queue_restore_data *qrd) +{ + struct cik_sdma_rlc_registers *m; + m = get_sdma_mqd(mqd); + + memcpy(qrd->mqd, m, sizeof(struct cik_sdma_rlc_registers)); +} + +static void restore_mqd_sdma(struct mqd_manager *mm, void **mqd, + struct kfd_mem_obj *mqd_mem_obj, uint64_t *gart_addr, + struct queue_properties *qp, + const struct queue_restore_data *qrd) +{ + uint64_t addr; + struct cik_sdma_rlc_registers *m; + + m = (struct cik_sdma_rlc_registers *) mqd_mem_obj->cpu_ptr; + addr = mqd_mem_obj->gpu_addr; + + memcpy(m, qrd->mqd, sizeof(*m)); + + *mqd = m; + if (gart_addr) + *gart_addr = addr; + + qp->is_active = 0; +} + /* * preempt type here is ignored because there is only one way * to preempt sdma queue @@ -388,6 +450,8 @@ struct mqd_manager *mqd_manager_init_cik(enum KFD_MQD_TYPE type, mqd->update_mqd = update_mqd; mqd->destroy_mqd = destroy_mqd; mqd->is_occupied = is_occupied; + mqd->dump_mqd = dump_mqd; + mqd->restore_mqd = restore_mqd; mqd->mqd_size = sizeof(struct cik_mqd); #if defined(CONFIG_DEBUG_FS) mqd->debugfs_show_mqd = debugfs_show_mqd; @@ -428,6 +492,8 @@ struct mqd_manager *mqd_manager_init_cik(enum KFD_MQD_TYPE type, mqd->update_mqd = update_mqd_sdma; mqd->destroy_mqd = destroy_mqd_sdma; mqd->is_occupied = is_occupied_sdma; + mqd->dump_mqd = dump_mqd_sdma; + mqd->restore_mqd = restore_mqd_sdma; mqd->mqd_size = sizeof(struct cik_sdma_rlc_registers); #if defined(CONFIG_DEBUG_FS) mqd->debugfs_show_mqd = debugfs_show_mqd_sdma; diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c index c7fb59ca597f..126c0dc63f10 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c @@ -283,6 +283,40 @@ static int get_wave_state(struct mqd_manager *mm, void *mqd, return 0; } +static void dump_mqd(struct mqd_manager *mm, void *mqd, + struct queue_restore_data *qrd) +{ + struct v10_compute_mqd *m; + m = get_mqd(mqd); + + memcpy(qrd->mqd, m, sizeof(struct v10_compute_mqd)); +} + +static void restore_mqd(struct mqd_manager *mm, void **mqd, + struct kfd_mem_obj *mqd_mem_obj, uint64_t *gart_addr, + struct queue_properties *qp, + const struct queue_restore_data *qrd) +{ + uint64_t addr; + struct v10_compute_mqd *m; + m = (struct v10_compute_mqd *) mqd_mem_obj->cpu_ptr; + addr = mqd_mem_obj->gpu_addr; + + memcpy(m, qrd->mqd, sizeof(*m)); + + *mqd = m; + if (gart_addr) + *gart_addr = addr; + + m->cp_hqd_pq_doorbell_control = + qp->doorbell_off << + CP_HQD_PQ_DOORBELL_CONTROL__DOORBELL_OFFSET__SHIFT; + pr_debug("cp_hqd_pq_doorbell_control 0x%x\n", + m->cp_hqd_pq_doorbell_control); + + qp->is_active = 0; +} + static void init_mqd_hiq(struct mqd_manager *mm, void **mqd, struct kfd_mem_obj *mqd_mem_obj, uint64_t *gart_addr, struct queue_properties *q) @@ -370,6 +404,35 @@ static bool is_occupied_sdma(struct mqd_manager *mm, void *mqd, return mm->dev->kfd2kgd->hqd_sdma_is_occupied(mm->dev->kgd, mqd); } +static void dump_mqd_sdma(struct mqd_manager *mm, void *mqd, + struct queue_restore_data *qrd) +{ + struct v10_sdma_mqd *m; + m = get_sdma_mqd(mqd); + + memcpy(qrd->mqd, m, sizeof(struct v10_sdma_mqd)); +} + +static void restore_mqd_sdma(struct mqd_manager *mm, void **mqd, + struct kfd_mem_obj *mqd_mem_obj, uint64_t *gart_addr, + struct queue_properties *qp, + const struct queue_restore_data *qrd) +{ + uint64_t addr; + struct v10_sdma_mqd *m; + + m = (struct v10_sdma_mqd *) mqd_mem_obj->cpu_ptr; + addr = mqd_mem_obj->gpu_addr; + + memcpy(m, qrd->mqd, sizeof(*m)); + + *mqd = m; + if (gart_addr) + *gart_addr = addr; + + qp->is_active = 0; +} + #if defined(CONFIG_DEBUG_FS) static int debugfs_show_mqd(struct seq_file *m, void *data) @@ -414,6 +477,8 @@ struct mqd_manager *mqd_manager_init_v10(enum KFD_MQD_TYPE type, mqd->is_occupied = is_occupied; mqd->mqd_size = sizeof(struct v10_compute_mqd); mqd->get_wave_state = get_wave_state; + mqd->dump_mqd = dump_mqd; + mqd->restore_mqd = restore_mqd; #if defined(CONFIG_DEBUG_FS) mqd->debugfs_show_mqd = debugfs_show_mqd; #endif @@ -458,6 +523,8 @@ struct mqd_manager *mqd_manager_init_v10(enum KFD_MQD_TYPE type, mqd->destroy_mqd = destroy_mqd_sdma; mqd->is_occupied = is_occupied_sdma; mqd->mqd_size = sizeof(struct v10_sdma_mqd); + mqd->dump_mqd = dump_mqd_sdma; + mqd->restore_mqd = restore_mqd_sdma; #if defined(CONFIG_DEBUG_FS) mqd->debugfs_show_mqd = debugfs_show_mqd_sdma; #endif diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c index 7f4e102ff4bd..8318192920e4 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c @@ -338,6 +338,41 @@ static int get_wave_state(struct mqd_manager *mm, void *mqd, return 0; } +static void dump_mqd(struct mqd_manager *mm, void *mqd, + struct queue_restore_data *qrd) +{ + struct v9_mqd *m; + m = get_mqd(mqd); + + memcpy(qrd->mqd, m, sizeof(struct v9_mqd)); +} + +static void restore_mqd(struct mqd_manager *mm, void **mqd, + struct kfd_mem_obj *mqd_mem_obj, uint64_t *gart_addr, + struct queue_properties *qp, + const struct queue_restore_data *qrd) +{ + uint64_t addr; + struct v9_mqd *m; + m = (struct v9_mqd *) mqd_mem_obj->cpu_ptr; + addr = mqd_mem_obj->gpu_addr; + + memcpy(m, qrd->mqd, sizeof(*m)); + + *mqd = m; + if (gart_addr) + *gart_addr = addr; + + /* Control stack is located one page after MQD. */ + m->cp_hqd_pq_doorbell_control = + qp->doorbell_off << + CP_HQD_PQ_DOORBELL_CONTROL__DOORBELL_OFFSET__SHIFT; + pr_debug("cp_hqd_pq_doorbell_control 0x%x\n", + m->cp_hqd_pq_doorbell_control); + + qp->is_active = 0; +} + static void init_mqd_hiq(struct mqd_manager *mm, void **mqd, struct kfd_mem_obj *mqd_mem_obj, uint64_t *gart_addr, struct queue_properties *q) @@ -425,6 +460,35 @@ static bool is_occupied_sdma(struct mqd_manager *mm, void *mqd, return mm->dev->kfd2kgd->hqd_sdma_is_occupied(mm->dev->kgd, mqd); } +static void dump_mqd_sdma(struct mqd_manager *mm, void *mqd, + struct queue_restore_data *qrd) +{ + struct v9_sdma_mqd *m; + m = get_sdma_mqd(mqd); + + memcpy(qrd->mqd, m, sizeof(struct v9_sdma_mqd)); +} + +static void restore_mqd_sdma(struct mqd_manager *mm, void **mqd, + struct kfd_mem_obj *mqd_mem_obj, uint64_t *gart_addr, + struct queue_properties *qp, + const struct queue_restore_data *qrd) +{ + uint64_t addr; + struct v9_sdma_mqd *m; + + m = (struct v9_sdma_mqd *) mqd_mem_obj->cpu_ptr; + addr = mqd_mem_obj->gpu_addr; + + memcpy(m, qrd->mqd, sizeof(*m)); + + *mqd = m; + if (gart_addr) + *gart_addr = addr; + + qp->is_active = 0; +} + #if defined(CONFIG_DEBUG_FS) static int debugfs_show_mqd(struct seq_file *m, void *data) @@ -467,6 +531,8 @@ struct mqd_manager *mqd_manager_init_v9(enum KFD_MQD_TYPE type, mqd->destroy_mqd = destroy_mqd; mqd->is_occupied = is_occupied; mqd->get_wave_state = get_wave_state; + mqd->dump_mqd = dump_mqd; + mqd->restore_mqd = restore_mqd; mqd->mqd_size = sizeof(struct v9_mqd); #if defined(CONFIG_DEBUG_FS) mqd->debugfs_show_mqd = debugfs_show_mqd; @@ -507,6 +573,8 @@ struct mqd_manager *mqd_manager_init_v9(enum KFD_MQD_TYPE type, mqd->update_mqd = update_mqd_sdma; mqd->destroy_mqd = destroy_mqd_sdma; mqd->is_occupied = is_occupied_sdma; + mqd->dump_mqd = dump_mqd_sdma; + mqd->restore_mqd = restore_mqd_sdma; mqd->mqd_size = sizeof(struct v9_sdma_mqd); #if defined(CONFIG_DEBUG_FS) mqd->debugfs_show_mqd = debugfs_show_mqd_sdma; diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c index 33dbd22d290f..ff436737b717 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c @@ -303,6 +303,40 @@ static int get_wave_state(struct mqd_manager *mm, void *mqd, return 0; } +static void dump_mqd(struct mqd_manager *mm, void *mqd, + struct queue_restore_data *qrd) +{ + struct vi_mqd *m; + m = get_mqd(mqd); + + memcpy(qrd->mqd, m, sizeof(struct vi_mqd)); +} + +static void restore_mqd(struct mqd_manager *mm, void **mqd, + struct kfd_mem_obj *mqd_mem_obj, uint64_t *gart_addr, + struct queue_properties *qp, + const struct queue_restore_data *qrd) +{ + uint64_t addr; + struct vi_mqd *m; + m = (struct vi_mqd *) mqd_mem_obj->cpu_ptr; + addr = mqd_mem_obj->gpu_addr; + + memcpy(m, qrd->mqd, sizeof(*m)); + + *mqd = m; + if (gart_addr) + *gart_addr = addr; + + m->cp_hqd_pq_doorbell_control = + qp->doorbell_off << + CP_HQD_PQ_DOORBELL_CONTROL__DOORBELL_OFFSET__SHIFT; + pr_debug("cp_hqd_pq_doorbell_control 0x%x\n", + m->cp_hqd_pq_doorbell_control); + + qp->is_active = 0; +} + static void init_mqd_hiq(struct mqd_manager *mm, void **mqd, struct kfd_mem_obj *mqd_mem_obj, uint64_t *gart_addr, struct queue_properties *q) @@ -394,6 +428,35 @@ static bool is_occupied_sdma(struct mqd_manager *mm, void *mqd, return mm->dev->kfd2kgd->hqd_sdma_is_occupied(mm->dev->kgd, mqd); } +static void dump_mqd_sdma(struct mqd_manager *mm, void *mqd, + struct queue_restore_data *qrd) +{ + struct vi_sdma_mqd *m; + m = get_sdma_mqd(mqd); + + memcpy(qrd->mqd, m, sizeof(struct vi_sdma_mqd)); +} + +static void restore_mqd_sdma(struct mqd_manager *mm, void **mqd, + struct kfd_mem_obj *mqd_mem_obj, uint64_t *gart_addr, + struct queue_properties *qp, + const struct queue_restore_data *qrd) +{ + uint64_t addr; + struct vi_sdma_mqd *m; + + m = (struct vi_sdma_mqd *) mqd_mem_obj->cpu_ptr; + addr = mqd_mem_obj->gpu_addr; + + memcpy(m, qrd->mqd, sizeof(*m)); + + *mqd = m; + if (gart_addr) + *gart_addr = addr; + + qp->is_active = 0; +} + #if defined(CONFIG_DEBUG_FS) static int debugfs_show_mqd(struct seq_file *m, void *data) @@ -436,6 +499,8 @@ struct mqd_manager *mqd_manager_init_vi(enum KFD_MQD_TYPE type, mqd->destroy_mqd = destroy_mqd; mqd->is_occupied = is_occupied; mqd->get_wave_state = get_wave_state; + mqd->dump_mqd = dump_mqd; + mqd->restore_mqd = restore_mqd; mqd->mqd_size = sizeof(struct vi_mqd); #if defined(CONFIG_DEBUG_FS) mqd->debugfs_show_mqd = debugfs_show_mqd; @@ -476,6 +541,8 @@ struct mqd_manager *mqd_manager_init_vi(enum KFD_MQD_TYPE type, mqd->update_mqd = update_mqd_sdma; mqd->destroy_mqd = destroy_mqd_sdma; mqd->is_occupied = is_occupied_sdma; + mqd->dump_mqd = dump_mqd_sdma; + mqd->restore_mqd = restore_mqd_sdma; mqd->mqd_size = sizeof(struct vi_sdma_mqd); #if defined(CONFIG_DEBUG_FS) mqd->debugfs_show_mqd = debugfs_show_mqd_sdma; diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h index 55180a6fe102..defea19c8bb9 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h +++ b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h @@ -476,6 +476,8 @@ struct queue_restore_data { void *cu_mask; uint32_t cu_mask_size; + void *mqd; + uint32_t mqd_size; }; struct queue_properties { @@ -1087,6 +1089,12 @@ int pqm_get_wave_state(struct process_queue_manager *pqm, int amdkfd_fence_wait_timeout(uint64_t *fence_addr, uint64_t fence_value, unsigned int timeout_ms); +int pqm_get_queue_dump_info(struct process_queue_manager *pqm, + unsigned int qid, + u32 *mqd_size); +int pqm_dump_mqd(struct process_queue_manager *pqm, + unsigned int qid, + struct queue_restore_data* qrd); /* Packet Manager */ diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c index 0ca7db288b9f..8516e93b521b 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c @@ -527,6 +527,48 @@ int pqm_get_wave_state(struct process_queue_manager *pqm, save_area_used_size); } +int pqm_get_queue_dump_info(struct process_queue_manager *pqm, + unsigned int qid, + u32 *mqd_size) +{ + struct process_queue_node *pqn; + + pqn = get_queue_by_qid(pqm, qid); + if (!pqn) { + pr_debug("amdkfd: No queue %d exists for operation\n", qid); + return -EFAULT; + } + + if (!pqn->q->device->dqm->ops.get_queue_dump_info) { + pr_err("amdkfd: queue dumping not supported on this device\n"); + return -ENOTSUPP; + } + + pqn->q->device->dqm->ops.get_queue_dump_info(pqn->q->device->dqm, + pqn->q, mqd_size); + return 0; +} + +int pqm_dump_mqd(struct process_queue_manager *pqm, + unsigned int qid, struct queue_restore_data* qrd) +{ + struct process_queue_node *pqn; + + pqn = get_queue_by_qid(pqm, qid); + if (!pqn) { + pr_debug("amdkfd: No queue %d exists for operation\n", qid); + return -EFAULT; + } + + if (!pqn->q->device->dqm->ops.dump_mqd) { + pr_err("amdkfd: queue dumping not supported on this device\n"); + return -ENOTSUPP; + } + + return pqn->q->device->dqm->ops.dump_mqd(pqn->q->device->dqm, + pqn->q, qrd); +} + #if defined(CONFIG_DEBUG_FS) int pqm_debugfs_mqds(struct seq_file *m, void *data) From patchwork Sat May 1 01:57:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Kuehling X-Patchwork-Id: 12234589 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=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 A7B61C433B4 for ; Sat, 1 May 2021 01:58:56 +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 74AC261409 for ; Sat, 1 May 2021 01:58:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 74AC261409 Authentication-Results: mail.kernel.org; dmarc=fail (p=none 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 786246F64E; Sat, 1 May 2021 01:58:44 +0000 (UTC) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2078.outbound.protection.outlook.com [40.107.223.78]) by gabe.freedesktop.org (Postfix) with ESMTPS id E8E556F639; Sat, 1 May 2021 01:58:39 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aXogQJXS4tdEajfwOzusqx4XePmIpcOgRd4GyeuuPhJUuJuqVAYfGlt3dzwOpehfWQhgW6s61eNCrrzsQhgCz4a+xDQ4PQOR2kkB5It1Ltb3IXBZKAJH6i78Ld9T7RRR+dJP3Tsa6pqyqsMItA2Da0RZcKISCq4qctZ9WTzNU5Hnhe5OsNyG2mXkRQKW5ZieTw5Z7m9vZ0HzSjYy8/yv647onsghR91mw8rEzN2qs+afgUbzyOxFE2qIY3avDbbR2+m2ZOYMyHKSetT0kYJGGx2RxJLd71JoMQKhnJOySeKiO5wNIZKp8oF7uAHou1LGi7dMGL8Rd+3520D1bDzfLg== 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=Ysgf8kLhBax3YVgVuwLM5JSAhyMI4f5UwFggAcHvGFI=; b=a2r6toXkOzeJTpEqr8fuDBC9yeZaNbfxRlxxSF61UHfTcauHZAUQ8WNH0DtbjdFJ9gHG5cHMcxVv1YLcTQZwDGp0dc6oN+zqQLVSyuJ+0dIDcXHTysJUSCFUKLKxVJxkBJIstkERux6NDDy+T6Q9cdc3S7IPC2xmgaXfOHW7V+JJGzk1ZcJWOV1Y2EN1OnFPGQCqv3HjX7ENFwJS4eaKQkMZoZASUgBt6PcUxXx7EkqxPI/H4Q/tkm8MyW0dII4bumWlPpREVd8qJ5TxlcTaoxHkh2DlOnLxDT9rspxAb9JNxH+zz9TkVmlw/0GCEm1/0nO9J+2V+OD1WOBZWFowRw== 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=Ysgf8kLhBax3YVgVuwLM5JSAhyMI4f5UwFggAcHvGFI=; b=rBX79yUm2QgHFmHB/hfFc1TZrrK4iyI9QAMDkgtmrX0ogPJ0wvSe/jErl123eDlOQIzsUj6fRtXIZF7/cAaQS5jRbb9qAc+36aJ3nt5H+K8S1elGwJ8iuDJoJOGnG0etqWDQ4iAGwrt6UnApjfKiEw2gYqBIjRMhU02LW/whi+I= 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 BL0PR12MB4948.namprd12.prod.outlook.com (2603:10b6:208:1cc::20) by BL0PR12MB4932.namprd12.prod.outlook.com (2603:10b6:208:1c2::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.26; Sat, 1 May 2021 01:58:32 +0000 Received: from BL0PR12MB4948.namprd12.prod.outlook.com ([fe80::70f5:99ed:65a1:c033]) by BL0PR12MB4948.namprd12.prod.outlook.com ([fe80::70f5:99ed:65a1:c033%5]) with mapi id 15.20.4065.027; Sat, 1 May 2021 01:58:32 +0000 From: Felix Kuehling To: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [RFC PATCH 14/17] drm/amdkfd: CRIU dump/restore queue control stack Date: Fri, 30 Apr 2021 21:57:49 -0400 Message-Id: <20210501015752.888-15-Felix.Kuehling@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210501015752.888-1-Felix.Kuehling@amd.com> References: <20210501015752.888-1-Felix.Kuehling@amd.com> X-Originating-IP: [165.204.54.211] X-ClientProxiedBy: YT1PR01CA0037.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:2e::6) To BL0PR12MB4948.namprd12.prod.outlook.com (2603:10b6:208:1cc::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (165.204.54.211) by YT1PR01CA0037.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:2e::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.25 via Frontend Transport; Sat, 1 May 2021 01:58:31 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6608beed-4f25-45a3-5ea3-08d90c449f60 X-MS-TrafficTypeDiagnostic: BL0PR12MB4932: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:144; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: B/qZ6ovz5dP+qf+xO9EYbW4kXaRbTSQEPYwP4LvfkmhgLVmjH7cwj+vFPAo6+z3gD5h+xHYpP1/BgW0sYLqJAnggzhhNgnUVIOlcgxQlJ6Gog4CW5wAVwsKQ5wf5AhEs5zzKH6qm9XHitZAvt/5VX1txz8x9vk+dsA3gogziW6Ezwb/NPvA3d/6C25ZoPXkFVXCv3e9A1m4HJWfPHuD3XJE8XvIlQulWsMRXXz9/fPxGfCpqdCLjuk45dnZkYRU4/NbxGzWv9UZoonTtKDbxkGCeboHT7Pe8ZmzbNYr9mQmeng1NvyHtqHHcbQbwHJSC0F3Lqb9XFu4EwJnLfkc/Mt4XLTpSqP0Ku2Da5z+CHZMsbA+nemG5gYo6wPrKEppO+zKodRHoJOEcPxqDAt/Iz6uKJLYZhAKMGR9Tt1p8NuzYOkbgXJnmWoi0NZdNig15y/f+ewxiTVJgvMcVv4VQEq7AVTsdScyICpGNbqnxU9IB4QIeFmUxLr2jK1nF/lftzhm4R7/7iwlr+XQiHxYipWYa8kI2r3jnvoNugYYtLULtR1CBYaaXCXsNe6UyeQq7xDrLWN64EtaLnSnc//W8hDuTL49oNC+pjlGRL2dESnr60CBhTx/l8HTz66tpoe0fsNUUdvGQlsailE/7Fmmvu7t6nB6IlpFXRko6lRVP46CcYJ7NV++yOX2j7uou7m6h X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BL0PR12MB4948.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(39860400002)(346002)(136003)(366004)(396003)(6512007)(83380400001)(38350700002)(38100700002)(478600001)(26005)(16526019)(186003)(6486002)(86362001)(4326008)(316002)(54906003)(2616005)(956004)(450100002)(5660300002)(6666004)(66476007)(66556008)(52116002)(2906002)(6506007)(66946007)(8676002)(36756003)(8936002)(30864003)(1076003)(69590400013); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: iLuI5Cof0/bwqkAfrBv/sB5p9siulNcXPgex6DKOqd41YUDrDDiLwN3z4lE+VN6IRUH+8z9zo74hslXbqPJ1YS6JTkYl73gOXXzuIfRP2b3Pq6cArqENmQsz0DUKvcjqNAMyHU+eTfuB3lkTIVX+0Xq0h9nmY3AqAvNeGDgonJmCgWkEGvc2Bax6INH9L/zn7m0Xk/AWdE2idKkIKEsdmx9wVofu7Om8ulrtHO/BjU6cbeUoL3G/pfrATdhCDzXygYFnWWEIdixVsrACSpGmwlua+IiyL5qJVD8ZPryk5DrkiQLIXjOHF6AyUrYF7XjTcpkh9Nt+Bzuj5WYz0GTOzJ7jAn022nwC7SUCkNOPq0y3JCqsV9TvvzXfJOS6Y8quc0eJGcRihi0gwSFuMvlVNKC40aFWdbeTaDhsYJ2prrODDpHQDHsDnr/qBCmiL+fLcI7vTIuHs7/cx4Y/doeZpLUxoqzkZiCR0r5kpIPmVLrUGjJEAQRVIwqcnvewAnPZfGhZ/eYVL7g3DbXK2DuFlJHDpE1STE1Jk6NCGfZt66XXckgIG5OTePiM9BxzqG9qGu1rYIu3wQu5FspkJlKFpw3QU7cdDr96jR1JLR0Qozp9qxtt7MkDzErgScq6WLoat2P9M7f5X2vV44yymqwcTwY9I0jPPSuQ54J1XefkHQqnNsWxdB+e/7997nwleBcKWti/G+ToYkqLo91c6SNszuoqgw11t3ahQi192kc1TJQcELflVHXu+w4oGhp3fuQTRiXVTEP9F0wRjfqf6nKhauRRvV0aDHgzCiqiqnZ9A3Ut21ZMhZnM2mKGyZIFKHW9DbSD8eTjL//eEMoqHwlbLrOc+6/OUkzQbWI7ozRaVX3ukd+nP36qwufaZN8NjuEIo079Mr/FvUAWeXaJx95R+QMiMO52mS0wLxwejwehOm31UIk+lPkhjgV4Sc3WoOQpF2Z3j2rvYLGYV6sH9FrgYTB0g5KcCVR7BmGVKUs0fqdqe1t65gENpWb5tMWssbPhcvoa4lh2bME/K6BsFmhpDsp2wXJE5G3CShLCwVDOGgdNjUBhLSOE3hHptUzUxicXGyzXxaNCbqYutNEBNDNHAlU/QIA4b1sCeH3x+gxhdSckbgm3KaKiDZncj+Cf8JhxEX8b3hDAK/BYmKx7VkohFBwSWxwA2t/skFmPBF29ASxxK2nAxu7L9S7ayfTuRkjJjqAVQ2ooftb6wVCdRoe0PPFCT6p6mguldj5ZrcvgpFiNvkZ/OnU38VVZS8aUVekeHBoCyrYCxzZweI6f4UZ3JnM18DmzvfElHaCTcNcWL7UIFE7wJGYrlNkyTH60mfOs X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6608beed-4f25-45a3-5ea3-08d90c449f60 X-MS-Exchange-CrossTenant-AuthSource: BL0PR12MB4948.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 May 2021 01:58:32.2690 (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: 6HZP4ey62sLIOqO40RsshGpaFQ4L785udOLVl3w2bFKHAdUN/HumyerMp+uhNDkK5MYVOWzE0YJXPelVLgJeug== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR12MB4932 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: David Yat Sin , Rajneesh Bhardwaj Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: David Yat Sin Dump contents of queue control stacks on CRIU dump and restore them during CRIU restore. (rajneesh: rebased to 5.11 and fixed merge conflict) Signed-off-by: Rajneesh Bhardwaj Signed-off-by: David Yat Sin Change-Id: Ia1f38f3d4309e1f026981b16d26306672f3bf266 --- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 32 +++++++++++++++---- .../drm/amd/amdkfd/kfd_device_queue_manager.c | 10 +++++- .../drm/amd/amdkfd/kfd_device_queue_manager.h | 4 +-- drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.h | 3 ++ .../gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c | 8 +++++ .../gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c | 8 +++++ .../gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c | 18 +++++++++++ .../gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c | 8 +++++ drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 6 ++-- .../amd/amdkfd/kfd_process_queue_manager.c | 8 ++--- 10 files changed, 89 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c index b7f3aa759c17..71f734eae071 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c @@ -1894,13 +1894,15 @@ static int kfd_devinfo_restore(struct kfd_process *p, struct kfd_criu_devinfo_bu static int get_queue_data_sizes(struct kfd_process_device *pdd, struct queue *q, uint32_t *cu_mask_size, - uint32_t *mqd_size) + uint32_t *mqd_size, + uint32_t *ctl_stack_size) { int ret = 0; *cu_mask_size = sizeof(uint32_t) * (q->properties.cu_mask_count / 32); - ret = pqm_get_queue_dump_info(&pdd->process->pqm, q->properties.queue_id, mqd_size); + ret = pqm_get_queue_dump_info(&pdd->process->pqm, + q->properties.queue_id, mqd_size, ctl_stack_size); if (ret) { pr_err("Failed to get queue dump info (%d)\n", ret); return ret; @@ -1941,6 +1943,8 @@ static int criu_dump_queue(struct kfd_process_device *pdd, q->properties.ctx_save_restore_area_size; q_bucket->ctl_stack_size = q->properties.ctl_stack_size; + + /* queue_data contains data in this order cu_mask, mqd, ctl_stack */ if (qrd->cu_mask_size) memcpy(qrd->cu_mask, q->properties.cu_mask, qrd->cu_mask_size); @@ -1952,6 +1956,7 @@ static int criu_dump_queue(struct kfd_process_device *pdd, q_bucket->cu_mask_size = qrd->cu_mask_size; q_bucket->mqd_size = qrd->mqd_size; + q_bucket->ctl_stack_size = qrd->ctl_stack_size; return ret; } @@ -1991,14 +1996,15 @@ static int criu_dump_queues_device(struct kfd_process_device *pdd, memset(&q_bucket, 0, sizeof(q_bucket)); memset(&qrd, 0, sizeof(qrd)); - ret = get_queue_data_sizes(pdd, q, &qrd.cu_mask_size, &qrd.mqd_size); + ret = get_queue_data_sizes(pdd, q, &qrd.cu_mask_size, + &qrd.mqd_size, &qrd.ctl_stack_size); if (ret) { pr_err("Failed to get queue dump info (%d)\n", ret); ret = -EFAULT; break; } - q_data_size = qrd.cu_mask_size + qrd.mqd_size; + q_data_size = qrd.cu_mask_size + qrd.mqd_size + qrd.ctl_stack_size; /* Increase local buffer space if needed */ if (data_ptr_size < q_data_size) { @@ -2013,8 +2019,11 @@ static int criu_dump_queues_device(struct kfd_process_device *pdd, data_ptr_size = q_data_size; } + /* data stored in this order: cu_mask, mqd, mqd_ctl_stack */ qrd.cu_mask = data_ptr; qrd.mqd = data_ptr + qrd.cu_mask_size; + qrd.mqd_ctl_stack = qrd.mqd + qrd.mqd_size; + ret = criu_dump_queue(pdd, q, &q_bucket, &qrd); if (ret) break; @@ -2334,7 +2343,8 @@ static int criu_restore_queues(struct kfd_process *p, return ret; } - q_data_size = q_bucket.cu_mask_size + q_bucket.mqd_size; + q_data_size = q_bucket.cu_mask_size + q_bucket.mqd_size + + q_bucket.ctl_stack_size; /* Increase local buffer space if needed */ if (q_data_size > data_ptr_size) { @@ -2363,6 +2373,9 @@ static int criu_restore_queues(struct kfd_process *p, qrd.mqd_size = q_bucket.mqd_size; qrd.mqd = data_ptr + qrd.cu_mask_size; + qrd.ctl_stack_size = q_bucket.ctl_stack_size; + qrd.mqd_ctl_stack = qrd.mqd + qrd.mqd_size; + ret = criu_restore_queue(p, dev, pdd, &q_bucket, &qrd); if (ret) { pr_err("Failed to restore queue (%d)\n", ret); @@ -2701,11 +2714,16 @@ static int kfd_ioctl_criu_helper(struct file *filep, u32 cu_mask_size = 0; u32 mqd_size = 0; - ret = get_queue_data_sizes(pdd, q, &cu_mask_size, &mqd_size); + u32 ctl_stack_size = 0; + + ret = get_queue_data_sizes(pdd, q, + &cu_mask_size, &mqd_size, + &ctl_stack_size); if (ret) goto err_unlock; - queues_data_size += cu_mask_size + mqd_size; + queues_data_size += cu_mask_size + mqd_size + + ctl_stack_size; q_index++; } else { pr_err("Unsupported queue type (%d)\n", q->properties.type); diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c index ee34229a41b0..04adc374b185 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c @@ -1756,14 +1756,22 @@ static int get_wave_state(struct device_queue_manager *dqm, static void get_queue_dump_info(struct device_queue_manager *dqm, const struct queue *q, - u32 *mqd_size) + u32 *mqd_size, + u32 *ctl_stack_size) { struct mqd_manager *mqd_mgr; enum KFD_MQD_TYPE mqd_type = get_mqd_type_from_queue_type(q->properties.type); + dqm_lock(dqm); mqd_mgr = dqm->mqd_mgrs[mqd_type]; *mqd_size = mqd_mgr->mqd_size; + *ctl_stack_size = 0; + + if (q->properties.type == KFD_QUEUE_TYPE_COMPUTE && mqd_mgr->get_dump_info) + mqd_mgr->get_dump_info(mqd_mgr, q->mqd, ctl_stack_size); + + dqm_unlock(dqm); } static int dump_mqd(struct device_queue_manager *dqm, diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.h b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.h index 27952e33a404..c04af287d5a0 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.h +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.h @@ -137,8 +137,8 @@ struct device_queue_manager_ops { u32 *save_area_used_size); void (*get_queue_dump_info)(struct device_queue_manager *dqm, - const struct queue *q, - u32 *mqd_size); + const struct queue *q, u32 *mqd_size, + u32 *ctl_stack_size); int (*dump_mqd)(struct device_queue_manager *dqm, const struct queue *q, diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.h b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.h index 82da00bc71aa..07cc34e5a31a 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.h +++ b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.h @@ -98,6 +98,9 @@ struct mqd_manager { u32 *ctl_stack_used_size, u32 *save_area_used_size); + void (*get_dump_info)(struct mqd_manager *mm, void *mqd, + uint32_t *ctl_stack_size); + void (*dump_mqd)(struct mqd_manager *mm, void *mqd, struct queue_restore_data *qrd); diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c index 3f59466a5104..98b2b3b9c740 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c @@ -275,6 +275,13 @@ static int destroy_mqd(struct mqd_manager *mm, void *mqd, pipe_id, queue_id); } +static void get_dump_info(struct mqd_manager *mm, void *mqd, + u32 *ctl_stack_size) +{ + /* Control stack is stored in user mode */ + *ctl_stack_size = 0; +} + static void dump_mqd(struct mqd_manager *mm, void *mqd, struct queue_restore_data *qrd) { @@ -450,6 +457,7 @@ struct mqd_manager *mqd_manager_init_cik(enum KFD_MQD_TYPE type, mqd->update_mqd = update_mqd; mqd->destroy_mqd = destroy_mqd; mqd->is_occupied = is_occupied; + mqd->get_dump_info = get_dump_info; mqd->dump_mqd = dump_mqd; mqd->restore_mqd = restore_mqd; mqd->mqd_size = sizeof(struct cik_mqd); diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c index 126c0dc63f10..c4c05a71352d 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c @@ -283,6 +283,13 @@ static int get_wave_state(struct mqd_manager *mm, void *mqd, return 0; } +static void get_dump_info(struct mqd_manager *mm, void *mqd, + u32 *ctl_stack_size) +{ + /* Control stack is stored in user mode */ + *ctl_stack_size = 0; +} + static void dump_mqd(struct mqd_manager *mm, void *mqd, struct queue_restore_data *qrd) { @@ -477,6 +484,7 @@ struct mqd_manager *mqd_manager_init_v10(enum KFD_MQD_TYPE type, mqd->is_occupied = is_occupied; mqd->mqd_size = sizeof(struct v10_compute_mqd); mqd->get_wave_state = get_wave_state; + mqd->get_dump_info = get_dump_info; mqd->dump_mqd = dump_mqd; mqd->restore_mqd = restore_mqd; #if defined(CONFIG_DEBUG_FS) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c index 8318192920e4..68cd108c2f9a 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c @@ -338,13 +338,24 @@ static int get_wave_state(struct mqd_manager *mm, void *mqd, return 0; } +static void get_dump_info(struct mqd_manager *mm, void *mqd, u32 *ctl_stack_size) +{ + struct v9_mqd *m = get_mqd(mqd); + + *ctl_stack_size = m->cp_hqd_cntl_stack_size; +} + static void dump_mqd(struct mqd_manager *mm, void *mqd, struct queue_restore_data *qrd) { struct v9_mqd *m; + /* Control stack is located one page after MQD. */ + void *mqd_ctl_stack = (void *)((uintptr_t)mqd + PAGE_SIZE); + m = get_mqd(mqd); memcpy(qrd->mqd, m, sizeof(struct v9_mqd)); + memcpy(qrd->mqd_ctl_stack, mqd_ctl_stack, m->cp_hqd_cntl_stack_size); } static void restore_mqd(struct mqd_manager *mm, void **mqd, @@ -354,6 +365,8 @@ static void restore_mqd(struct mqd_manager *mm, void **mqd, { uint64_t addr; struct v9_mqd *m; + void *mqd_ctl_stack; + m = (struct v9_mqd *) mqd_mem_obj->cpu_ptr; addr = mqd_mem_obj->gpu_addr; @@ -364,6 +377,10 @@ static void restore_mqd(struct mqd_manager *mm, void **mqd, *gart_addr = addr; /* Control stack is located one page after MQD. */ + mqd_ctl_stack = (void *)((uintptr_t)*mqd + PAGE_SIZE); + memcpy(mqd_ctl_stack, qrd->mqd_ctl_stack, qrd->ctl_stack_size); + + /* TODO: Confirm that qp->doorbell_off is restored properly */ m->cp_hqd_pq_doorbell_control = qp->doorbell_off << CP_HQD_PQ_DOORBELL_CONTROL__DOORBELL_OFFSET__SHIFT; @@ -531,6 +548,7 @@ struct mqd_manager *mqd_manager_init_v9(enum KFD_MQD_TYPE type, mqd->destroy_mqd = destroy_mqd; mqd->is_occupied = is_occupied; mqd->get_wave_state = get_wave_state; + mqd->get_dump_info = get_dump_info; mqd->dump_mqd = dump_mqd; mqd->restore_mqd = restore_mqd; mqd->mqd_size = sizeof(struct v9_mqd); diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c index ff436737b717..9ae3a16ae69b 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c @@ -303,6 +303,13 @@ static int get_wave_state(struct mqd_manager *mm, void *mqd, return 0; } +static void get_dump_info(struct mqd_manager *mm, void *mqd, + u32 *ctl_stack_size) +{ + /* Control stack is stored in user mode */ + *ctl_stack_size = 0; +} + static void dump_mqd(struct mqd_manager *mm, void *mqd, struct queue_restore_data *qrd) { @@ -499,6 +506,7 @@ struct mqd_manager *mqd_manager_init_vi(enum KFD_MQD_TYPE type, mqd->destroy_mqd = destroy_mqd; mqd->is_occupied = is_occupied; mqd->get_wave_state = get_wave_state; + mqd->get_dump_info = get_dump_info; mqd->dump_mqd = dump_mqd; mqd->restore_mqd = restore_mqd; mqd->mqd_size = sizeof(struct vi_mqd); diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h index defea19c8bb9..3ebca0a4e046 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h +++ b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h @@ -478,6 +478,8 @@ struct queue_restore_data { uint32_t cu_mask_size; void *mqd; uint32_t mqd_size; + void *mqd_ctl_stack; + uint32_t ctl_stack_size; }; struct queue_properties { @@ -1090,8 +1092,8 @@ int amdkfd_fence_wait_timeout(uint64_t *fence_addr, uint64_t fence_value, unsigned int timeout_ms); int pqm_get_queue_dump_info(struct process_queue_manager *pqm, - unsigned int qid, - u32 *mqd_size); + unsigned int qid, + u32 *mqd_size, u32 *ctl_stack_size); int pqm_dump_mqd(struct process_queue_manager *pqm, unsigned int qid, struct queue_restore_data* qrd); diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c index 8516e93b521b..815a28b88a9c 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c @@ -527,9 +527,8 @@ int pqm_get_wave_state(struct process_queue_manager *pqm, save_area_used_size); } -int pqm_get_queue_dump_info(struct process_queue_manager *pqm, - unsigned int qid, - u32 *mqd_size) +int pqm_get_queue_dump_info(struct process_queue_manager *pqm, unsigned int qid, + u32 *mqd_size, u32 *ctl_stack_size) { struct process_queue_node *pqn; @@ -545,7 +544,8 @@ int pqm_get_queue_dump_info(struct process_queue_manager *pqm, } pqn->q->device->dqm->ops.get_queue_dump_info(pqn->q->device->dqm, - pqn->q, mqd_size); + pqn->q, mqd_size, + ctl_stack_size); return 0; } From patchwork Sat May 1 01:57:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Kuehling X-Patchwork-Id: 12234587 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=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 A728AC43462 for ; Sat, 1 May 2021 01:58:55 +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 6B60761409 for ; Sat, 1 May 2021 01:58:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6B60761409 Authentication-Results: mail.kernel.org; dmarc=fail (p=none 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 77EBB6F63A; Sat, 1 May 2021 01:58:42 +0000 (UTC) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2078.outbound.protection.outlook.com [40.107.223.78]) by gabe.freedesktop.org (Postfix) with ESMTPS id A908C6F638; Sat, 1 May 2021 01:58:39 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fEh9XImaD6hhJ8Jem9HjhUrvG2q0VzECOHxis4aJUf3VfKaUGwULb3mOVLtIDONE+Q4EwGoLzIhZHPkvV3Xzs0bfIxrzVB4Mlk+6WwfIZoDkewjB4qLEtnLpTEN8FAHxz492v2HksbbNwHLMTHCX8w8xw2nHGNqhAneoEERgmNXGhf8c9RQhmkTpUQsoZTHLYFJ7tp/dmg1vWyWSpAqRzMFaV5up7dWbx6J56sWpmDFPbJdzOM/U4PJZNuU2ns+VN+Ouyb4VXQGc5+NNhgiFEnwrVBJVLa8/cqfghV7e4HCbC71bZIFo4N7gjchHCmGWhT/5umecudxpJ/3Q853vwg== 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=VNSGdEVZFgWn4ZbgRkJ7NmoVBO1Q0U9W0PseUgjbgYo=; b=GoIkRcxiXWIGcXdeJX0jUl9MpGAH5nTtiOmGXwUNVbWqp6PVEnN7doup+YmfjYTOZW98TWQb4B85iO+Clg8gj6CywokKczPE0mdIfLiks07xSgH763Ehb/NWsNheABbeKTfVz8Vu0IES2Cutp8gerufv72L8Ke8O6Q4MfAagL8wZG2SHbKijkCBi+lounW7Kjm7Thl0gRafXFHnqe/236m3W3/ocPkxei3nIizIn7NCnVcu2Aa5YUnvaZ85XP55HTYK63RRVXeduz6FU2UFe61Eq4gZN+mJAA+W7zKMRMvgYgFEmzNChEjSeNh7G5XPQn/69T6i3EnkAeNno44NE+Q== 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=VNSGdEVZFgWn4ZbgRkJ7NmoVBO1Q0U9W0PseUgjbgYo=; b=VSsiNuqwAYtiNKiLdUJco/fxsQM13ynGoHj5yqA7HaTzIWGTeftzbNPN8jFcNf3qtehtJReDWeuH6jOhANpLr3NPiMpGyBkl4I420YCOMDMZv0zewB8+qvHuPRt/1EInYfK3LdYufy+a6ONRyflPsJuuFaLrKM5TJU/yzcMUMLs= 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 BL0PR12MB4948.namprd12.prod.outlook.com (2603:10b6:208:1cc::20) by BL0PR12MB4932.namprd12.prod.outlook.com (2603:10b6:208:1c2::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.26; Sat, 1 May 2021 01:58:33 +0000 Received: from BL0PR12MB4948.namprd12.prod.outlook.com ([fe80::70f5:99ed:65a1:c033]) by BL0PR12MB4948.namprd12.prod.outlook.com ([fe80::70f5:99ed:65a1:c033%5]) with mapi id 15.20.4065.027; Sat, 1 May 2021 01:58:33 +0000 From: Felix Kuehling To: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [RFC PATCH 15/17] drm/amdkfd: CRIU dump and restore events Date: Fri, 30 Apr 2021 21:57:50 -0400 Message-Id: <20210501015752.888-16-Felix.Kuehling@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210501015752.888-1-Felix.Kuehling@amd.com> References: <20210501015752.888-1-Felix.Kuehling@amd.com> X-Originating-IP: [165.204.54.211] X-ClientProxiedBy: YT1PR01CA0037.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:2e::6) To BL0PR12MB4948.namprd12.prod.outlook.com (2603:10b6:208:1cc::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (165.204.54.211) by YT1PR01CA0037.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:2e::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.25 via Frontend Transport; Sat, 1 May 2021 01:58:32 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2829d318-edbf-4112-f38b-08d90c449fdc X-MS-TrafficTypeDiagnostic: BL0PR12MB4932: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:87; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YUlaOsfWbJGb3zZpb6Q4HOnLrK9nAL9qOdoDjzHrjN57cTA0gvpjIpWuamptRRAfUReDJU7TrNQJFmsAyAgRfwNYN3Lsbga2/hQ9Y4OZxi+8p6IJzgZc0vhfJKlNvA4NFizfbPitX/0QJEfAQhVTW+DxoPZrkmXzszw56GjGgYxIreAhlMaf5DNNiv44o6KILdwxmCpbgJLIoixWv0CE71JuRQT7fAXI5r9iI1niFrxp3alZnU54rXLyRofUF3qIEmRJDpN2yu6j0LIr15bgEmwFba+c9hUFfU46igUmTuMQx1u1lIgJoe1GALowzmlNZyRvjTSTWEjcM+qmeb3d1nWItFUEFrXoK0NOR4HcWWFUFRmLqNn6QN8GCeoAKbtiuIS2M/ZjlZcw1a/POuzhy6pZSSZ6bELFfHlB71tZzI/os9ZNyQGi0XiScASru7Iyp5gcT0w00qEjpODcG8MWBJNu1w9o2I/ApCKjHGElC4D1XcAY7+1D67eLSkbUtyb+seJVeSgUDB3ADXEvTh08MdBQqz56pm7/DIBXxz4ySHcEvi8EkZhxd0ug5FsHp4j0yZjtz0m2Mmtwrblry39IcvZmw52fnpQB6RxVdZ9/S9f7AJ6LlZlY3V7p1RIlIZrXDNVrol9MVhJKWbnKMbL+zEfam9mbGEvPl7CCBzetINFrWa10u/WlBxhLR7lfYbwE X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BL0PR12MB4948.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(39860400002)(346002)(136003)(366004)(396003)(6512007)(83380400001)(38350700002)(38100700002)(478600001)(26005)(16526019)(186003)(6486002)(86362001)(4326008)(316002)(2616005)(956004)(450100002)(5660300002)(6666004)(66476007)(66556008)(52116002)(2906002)(6506007)(66946007)(8676002)(36756003)(8936002)(30864003)(1076003)(69590400013); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: hZQnEDdWAmm9NLgi4NzUE7I6mYJeqGM8QQ/4bLmewNlHC5MfXnjNGzLe+Iki9fYoGU2DuDGFv+bYvjKX8evmakvMVIgZ2esTTnZTbXy8YDLSt/sYi2W0JfiUBVgsafInNsd+xIXOG+QIjehpZvdBkLqpCFA/SdIlQEFJ/B2HrFckPVSJuBfCcgu0yXT9MyDOOcF9i6f8Z+3zebhCpvLa9QBJ9UibFDtqlBJpLMhSsjCZBgFfll2wSwnzS9Qy8pkUj2k96CIXe+U3MsVX7tVv6merzGroUblwpIJaa1jLqiToO5iPJFjLbv9pJxJheo7+tPwoMJahZVJhurlXVj6HprDxH6oDiIwtjd1OU0YV2HkzF0jCRVq2CMnZ5ryucDiD9/eZYJOw3PIU6WwOg4Na5XJKoSimvxvyfc5r0wuunXKPyqFLwZGFThbEi8vNfUTHVI1w7uVDcdscgaRHhMbgaPPs1Wm8CU2Tm+73cWtQSyXeQFhDausyEti2t6qq+NNQnMdZQTm+DtFMu0Wdzgp7uGD4L4pR1lYIXkLPtAZGAJpIKghHB3kivXUXCbn/9MgOubdWOR+C9nEUGIge0Gy6rhCkxi1ZZY/91AdDUlx8UkPLgnZ/RW3iXliso2iXoU6VCux9wgXHn/F5my6NRn0IidOq7CPZciXvJzVssvs9eRiN8PqLAeeRus4aA8bwD7mDwnXP4m3+pcuQMwKw+X3J4DN3lqCvM4CsmNjwnd9LYMgV0GUWkPL9rM7olaX+0QKlyXkSG2xg5Ff1vNV0npt0b3X8Lex68OVtID6WdRHNuCNgVj/lBF+R8sgrnskZCm7x42FZO1BPewAfsuajq/IYvGtcV0vpLEJacHSIIE3DHtfII7kXisCVieIzNZiS36M4B+4mL+6NsFWVWrjnWG/WEKPmcgvLaN/K49xCXr77SQ0wJQFWxecCby5ooEZpr71RPgs4FR+f1saTzxbv6ZPOj8ve2Xxiui4cvSeN1ty1ZikQwpreni1qweGYIBlrPPLAEbi42wTvs05pB0KeUgcA5LKzsW1DIn9hv+pO9EkVczJbkHqTPdqwHGnpAtSJpls9VmN0ODkDyG7jkTZJXx59425EUI5gIMioQMF60IPiJzp3BN89FsogTWNQFNGb+AcccqWGZVsVA8B5mCZf9iEzCOHLWaLCOBKqzVbiYbnL7v2IkkbjYpRptIfJ93CUOZMb1Rknc4VoY5DIxPOO/Wk9HuFz9zmjsnusb/zRHLHn468CYOXOw3sf9NTALeE3IEDnD8BwjfO+FA2rPvCoRe8pI95/1MPBZ8yEZbOz5A/t4dNx4zYVhdErDvnAClxU9La9 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2829d318-edbf-4112-f38b-08d90c449fdc X-MS-Exchange-CrossTenant-AuthSource: BL0PR12MB4948.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 May 2021 01:58:33.0874 (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: Nf+DkLuW2+pib7/C0/ejaGNShY1laK/7Hcct65FxIPJ0nG1rCP3Ja5sTO2yUxxbleTFuXE5vRHz65xwtxbaR1g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR12MB4932 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: David Yat Sin Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: David Yat Sin Add support to existing CRIU ioctl's to save and restore events during criu checkpoint and restore. Signed-off-by: David Yat Sin Change-Id: I1635b1fa91a81abcbd19290cb88c8ca142c390e0 --- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 185 ++++++++++++++++------- drivers/gpu/drm/amd/amdkfd/kfd_events.c | 163 ++++++++++++++++---- drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 11 +- 3 files changed, 279 insertions(+), 80 deletions(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c index 71f734eae071..ce511b246beb 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c @@ -997,6 +997,55 @@ static int kfd_ioctl_get_process_apertures_new(struct file *filp, return 0; } +static int kmap_event_page(struct kfd_process *p, uint64_t event_page_offset) +{ + struct kfd_dev *kfd; + struct kfd_process_device *pdd; + void *mem, *kern_addr; + uint64_t size; + int err = 0; + + if (p->signal_page) { + pr_err("Event page is already set\n"); + return -EINVAL; + } + + kfd = kfd_device_by_id(GET_GPU_ID(event_page_offset)); + if (!kfd) { + pr_err("Getting device by id failed in %s\n", __func__); + return -EINVAL; + } + + pdd = kfd_bind_process_to_device(kfd, p); + if (IS_ERR(pdd)) { + mutex_unlock(&p->mutex); + return PTR_ERR(pdd); + } + + mem = kfd_process_device_translate_handle(pdd, + GET_IDR_HANDLE(event_page_offset)); + if (!mem) { + pr_err("Can't find BO, offset is 0x%llx\n", event_page_offset); + + mutex_unlock(&p->mutex); + return -EINVAL; + } + + err = amdgpu_amdkfd_gpuvm_map_gtt_bo_to_kernel(kfd->kgd, + mem, &kern_addr, &size); + if (err) { + pr_err("Failed to map event page to kernel\n"); + return err; + } + + err = kfd_event_page_set(p, kern_addr, size, event_page_offset); + if (err) { + pr_err("Failed to set event page\n"); + return err; + } + return err; +} + static int kfd_ioctl_create_event(struct file *filp, struct kfd_process *p, void *data) { @@ -1008,51 +1057,11 @@ static int kfd_ioctl_create_event(struct file *filp, struct kfd_process *p, * through the event_page_offset field. */ if (args->event_page_offset) { - struct kfd_dev *kfd; - struct kfd_process_device *pdd; - void *mem, *kern_addr; - uint64_t size; - - if (p->signal_page) { - pr_err("Event page is already set\n"); - return -EINVAL; - } - - kfd = kfd_device_by_id(GET_GPU_ID(args->event_page_offset)); - if (!kfd) { - pr_err("Getting device by id failed in %s\n", __func__); - return -EINVAL; - } - mutex_lock(&p->mutex); - pdd = kfd_bind_process_to_device(kfd, p); - if (IS_ERR(pdd)) { - err = PTR_ERR(pdd); - goto out_unlock; - } - - mem = kfd_process_device_translate_handle(pdd, - GET_IDR_HANDLE(args->event_page_offset)); - if (!mem) { - pr_err("Can't find BO, offset is 0x%llx\n", - args->event_page_offset); - err = -EINVAL; - goto out_unlock; - } + err = kmap_event_page(p, args->event_page_offset); mutex_unlock(&p->mutex); - - err = amdgpu_amdkfd_gpuvm_map_gtt_bo_to_kernel(kfd->kgd, - mem, &kern_addr, &size); - if (err) { - pr_err("Failed to map event page to kernel\n"); - return err; - } - - err = kfd_event_page_set(p, kern_addr, size); - if (err) { - pr_err("Failed to set event page\n"); + if (err) return err; - } } err = kfd_event_create(filp, p, args->event_type, @@ -1061,10 +1070,7 @@ static int kfd_ioctl_create_event(struct file *filp, struct kfd_process *p, &args->event_page_offset, &args->event_slot_index); - return err; - -out_unlock: - mutex_unlock(&p->mutex); + pr_debug("Created event (id:0x%08x) (%s)\n", args->event_id, __func__); return err; } @@ -2062,6 +2068,7 @@ static int kfd_ioctl_criu_dumper(struct file *filep, struct kfd_process *p, void *data) { struct kfd_ioctl_criu_dumper_args *args = data; + struct kfd_criu_ev_bucket *ev_buckets = NULL; struct kfd_criu_bo_buckets *bo_bucket; struct amdgpu_bo *dumper_bo; int ret, id, index, i = 0; @@ -2088,14 +2095,22 @@ static int kfd_ioctl_criu_dumper(struct file *filep, return -EINVAL; } - pr_debug("num of bos = %llu\n", args->num_of_bos); + pr_debug("num of bos = %llu queues = %u events = %u\n", args->num_of_bos, args->num_of_queues, args->num_of_events); bo_bucket = kvzalloc((sizeof(struct kfd_criu_bo_buckets) * args->num_of_bos), GFP_KERNEL); if (!bo_bucket) return -ENOMEM; - pr_debug("num of queues = %u\n", args->num_of_queues); + if (args->num_of_events) { + ev_buckets = kvzalloc((sizeof(struct kfd_criu_ev_bucket) * + args->num_of_events), GFP_KERNEL); + + if (!ev_buckets) { + ret = -ENOMEM; + goto clean; + } + } mutex_lock(&p->mutex); @@ -2182,6 +2197,23 @@ static int kfd_ioctl_criu_dumper(struct file *filep, goto err_unlock; } + /* Dump events */ + ret = kfd_event_dump(p, &args->event_page_offset, ev_buckets, + args->num_of_events); + if (ret) { + pr_err("failed to dump events, ret=%d\n", ret); + goto err_unlock; + } + ret = copy_to_user((void __user *)args->kfd_criu_ev_buckets_ptr, + ev_buckets, + (args->num_of_events * + sizeof(struct kfd_criu_ev_bucket))); + kvfree(ev_buckets); + if (ret) { + ret = -EFAULT; + goto err_unlock; + } + ret = copy_to_user((void __user *)args->kfd_criu_bo_buckets_ptr, bo_bucket, (args->num_of_bos * @@ -2195,6 +2227,8 @@ static int kfd_ioctl_criu_dumper(struct file *filep, err_unlock: kfd_process_restore_queues(p); mutex_unlock(&p->mutex); +clean: + kvfree(ev_buckets); pr_err("Dumper ioctl failed err:%d\n", ret); return ret; } @@ -2388,6 +2422,47 @@ static int criu_restore_queues(struct kfd_process *p, return ret; } +/* criu_restore_queues_events runs with the process mutex locked */ +static int criu_restore_events(struct file *filp, struct kfd_process *p, + struct kfd_ioctl_criu_restorer_args *args) +{ + int i; + struct kfd_criu_ev_bucket *events; + int ret = 0; + + if (args->event_page_offset) { + ret = kmap_event_page(p, args->event_page_offset); + if (ret) + return ret; + } + + if (!args->num_of_events) + return 0; + + events = kvmalloc_array(args->num_of_events, + sizeof(struct kfd_criu_ev_bucket), + GFP_KERNEL); + if (!events) + return -ENOMEM; + + ret = copy_from_user(events, (void __user *) args->kfd_criu_ev_buckets_ptr, + args->num_of_events * sizeof(struct kfd_criu_ev_bucket)); + + if (ret) { + ret = -EFAULT; + goto exit; + } + + for (i = 0; i < args->num_of_events; i++) { + ret = kfd_event_restore(filp, p, &events[i]); + if (ret) + pr_err("Failed to restore event with id (%d)\n", ret); + } +exit: + kvfree(events); + return ret; +} + static int kfd_ioctl_criu_restorer(struct file *filep, struct kfd_process *p, void *data) { @@ -2618,13 +2693,18 @@ static int kfd_ioctl_criu_restorer(struct file *filep, goto err_unlock; } + ret = criu_restore_events(filep, p, args); + if (ret) { + pr_err("Failed to restore events (%d)", ret); + err = ret; + goto err_unlock; + } + ret = copy_to_user((void __user *)args->restored_bo_array_ptr, restored_bo_offsets_arr, (args->num_of_bos * sizeof(*restored_bo_offsets_arr))); - if (ret) { + if (ret) err = -EFAULT; - goto err_unlock; - } err_unlock: mutex_unlock(&p->mutex); @@ -2739,8 +2819,9 @@ static int kfd_ioctl_criu_helper(struct file *filep, args->num_of_bos = num_of_bos; args->num_of_queues = q_index; args->queues_data_size = queues_data_size; - dev_dbg(kfd_device, "Num of bos = %llu\n", num_of_bos); + args->num_of_events = kfd_get_num_events(p); + dev_dbg(kfd_device, "Num of bos = %llu queues:%u events:%u\n", args->num_of_bos, args->num_of_queues, args->num_of_events); err_unlock: mutex_unlock(&p->mutex); return ret; diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_events.c b/drivers/gpu/drm/amd/amdkfd/kfd_events.c index ba2c2ce0c55a..c8d5458ba2c0 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_events.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_events.c @@ -53,9 +53,9 @@ struct kfd_signal_page { uint64_t *kernel_address; uint64_t __user *user_address; bool need_to_free_pages; + uint64_t user_handle; /* Needed for CRIU dumped and restore */ }; - static uint64_t *page_slots(struct kfd_signal_page *page) { return page->kernel_address; @@ -92,7 +92,8 @@ static struct kfd_signal_page *allocate_signal_page(struct kfd_process *p) } static int allocate_event_notification_slot(struct kfd_process *p, - struct kfd_event *ev) + struct kfd_event *ev, + const int *restore_id) { int id; @@ -104,14 +105,19 @@ static int allocate_event_notification_slot(struct kfd_process *p, p->signal_mapped_size = 256*8; } - /* - * Compatibility with old user mode: Only use signal slots - * user mode has mapped, may be less than - * KFD_SIGNAL_EVENT_LIMIT. This also allows future increase - * of the event limit without breaking user mode. - */ - id = idr_alloc(&p->event_idr, ev, 0, p->signal_mapped_size / 8, - GFP_KERNEL); + if (restore_id) { + id = idr_alloc(&p->event_idr, ev, *restore_id, *restore_id + 1, + GFP_KERNEL); + } else { + /* + * Compatibility with old user mode: Only use signal slots + * user mode has mapped, may be less than + * KFD_SIGNAL_EVENT_LIMIT. This also allows future increase + * of the event limit without breaking user mode. + */ + id = idr_alloc(&p->event_idr, ev, 0, p->signal_mapped_size / 8, + GFP_KERNEL); + } if (id < 0) return id; @@ -178,9 +184,8 @@ static struct kfd_event *lookup_signaled_event_by_partial_id( return ev; } -static int create_signal_event(struct file *devkfd, - struct kfd_process *p, - struct kfd_event *ev) +static int create_signal_event(struct file *devkfd, struct kfd_process *p, + struct kfd_event *ev, const int *restore_id) { int ret; @@ -193,7 +198,7 @@ static int create_signal_event(struct file *devkfd, return -ENOSPC; } - ret = allocate_event_notification_slot(p, ev); + ret = allocate_event_notification_slot(p, ev, restore_id); if (ret) { pr_warn("Signal event wasn't created because out of kernel memory\n"); return ret; @@ -209,16 +214,21 @@ static int create_signal_event(struct file *devkfd, return 0; } -static int create_other_event(struct kfd_process *p, struct kfd_event *ev) +static int create_other_event(struct kfd_process *p, struct kfd_event *ev, const int *restore_id) { - /* Cast KFD_LAST_NONSIGNAL_EVENT to uint32_t. This allows an - * intentional integer overflow to -1 without a compiler - * warning. idr_alloc treats a negative value as "maximum - * signed integer". - */ - int id = idr_alloc(&p->event_idr, ev, KFD_FIRST_NONSIGNAL_EVENT_ID, - (uint32_t)KFD_LAST_NONSIGNAL_EVENT_ID + 1, - GFP_KERNEL); + int id; + if (restore_id) + id = idr_alloc(&p->event_idr, ev, *restore_id, *restore_id + 1, + GFP_KERNEL); + else + /* Cast KFD_LAST_NONSIGNAL_EVENT to uint32_t. This allows an + * intentional integer overflow to -1 without a compiler + * warning. idr_alloc treats a negative value as "maximum + * signed integer". + */ + id = idr_alloc(&p->event_idr, ev, KFD_FIRST_NONSIGNAL_EVENT_ID, + (uint32_t)KFD_LAST_NONSIGNAL_EVENT_ID + 1, + GFP_KERNEL); if (id < 0) return id; @@ -296,7 +306,7 @@ static bool event_can_be_cpu_signaled(const struct kfd_event *ev) } int kfd_event_page_set(struct kfd_process *p, void *kernel_address, - uint64_t size) + uint64_t size, uint64_t user_handle) { struct kfd_signal_page *page; @@ -315,7 +325,7 @@ int kfd_event_page_set(struct kfd_process *p, void *kernel_address, p->signal_page = page; p->signal_mapped_size = size; - + p->signal_page->user_handle = user_handle; return 0; } @@ -343,14 +353,14 @@ int kfd_event_create(struct file *devkfd, struct kfd_process *p, switch (event_type) { case KFD_EVENT_TYPE_SIGNAL: case KFD_EVENT_TYPE_DEBUG: - ret = create_signal_event(devkfd, p, ev); + ret = create_signal_event(devkfd, p, ev, NULL); if (!ret) { *event_page_offset = KFD_MMAP_TYPE_EVENTS; *event_slot_index = ev->event_id; } break; default: - ret = create_other_event(p, ev); + ret = create_other_event(p, ev, NULL); break; } @@ -366,6 +376,105 @@ int kfd_event_create(struct file *devkfd, struct kfd_process *p, return ret; } +int kfd_event_restore(struct file *devkfd, struct kfd_process *p, + struct kfd_criu_ev_bucket *restore_ev) +{ + int ret = 0; + struct kfd_event *ev = kzalloc(sizeof(*ev), GFP_KERNEL); + + if (!ev) + return -ENOMEM; + + ev->type = restore_ev->type; + ev->auto_reset = restore_ev->auto_reset; + ev->signaled = restore_ev->signaled; + + init_waitqueue_head(&ev->wq); + + mutex_lock(&p->event_mutex); + switch (ev->type) { + case KFD_EVENT_TYPE_SIGNAL: + case KFD_EVENT_TYPE_DEBUG: + ret = create_signal_event(devkfd, p, ev, &restore_ev->event_id); + break; + case KFD_EVENT_TYPE_MEMORY: + memcpy(&ev->memory_exception_data, + &restore_ev->memory_exception_data, + sizeof(struct kfd_hsa_memory_exception_data)); + + ret = create_other_event(p, ev, &restore_ev->event_id); + break; + case KFD_EVENT_TYPE_HW_EXCEPTION: + memcpy(&ev->hw_exception_data, + &restore_ev->hw_exception_data, + sizeof(struct kfd_hsa_hw_exception_data)); + + ret = create_other_event(p, ev, &restore_ev->event_id); + break; + } + + if (ret) + kfree(ev); + + mutex_unlock(&p->event_mutex); + + return ret; +} + +int kfd_event_dump(struct kfd_process *p, uint64_t *user_handle, + struct kfd_criu_ev_bucket *ev_buckets, + uint32_t num_events) +{ + struct kfd_event *ev; + uint32_t ev_id; + int i = 0; + + *user_handle = 0; + + if (p->signal_page) + *user_handle = p->signal_page->user_handle; + + idr_for_each_entry(&p->event_idr, ev, ev_id) { + if (i >= num_events) { + pr_err("Number of events exceeds number allocated\n"); + return -ENOMEM; + } + + ev_buckets[i].event_id = ev->event_id; + ev_buckets[i].auto_reset = ev->auto_reset; + ev_buckets[i].type = ev->type; + ev_buckets[i].signaled = ev->signaled; + + if (ev_buckets[i].type == KFD_EVENT_TYPE_MEMORY) { + memcpy(&ev_buckets[i].memory_exception_data, + &ev->memory_exception_data, + sizeof(struct kfd_hsa_memory_exception_data)); + + } else if (ev_buckets[i].type == KFD_EVENT_TYPE_HW_EXCEPTION) { + memcpy(&ev_buckets[i].hw_exception_data, + &ev->hw_exception_data, + sizeof(struct kfd_hsa_hw_exception_data)); + } + pr_debug("Dumped event[%d] id = 0x%08x auto_reset = %x type = %x signaled = %x\n", + i, ev_buckets[i].event_id, ev_buckets[i].auto_reset, + ev_buckets[i].type, ev_buckets[i].signaled); + i++; + } + return 0; +} + +int kfd_get_num_events(struct kfd_process *p) +{ + struct kfd_event *ev; + uint32_t id; + u32 num_events = 0; + + idr_for_each_entry(&p->event_idr, ev, id) + num_events++; + + return num_events++; +} + /* Assumes that p is current. */ int kfd_event_destroy(struct kfd_process *p, uint32_t event_id) { diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h index 3ebca0a4e046..d3265860e78b 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h +++ b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h @@ -1190,11 +1190,20 @@ void kfd_signal_hw_exception_event(u32 pasid); int kfd_set_event(struct kfd_process *p, uint32_t event_id); int kfd_reset_event(struct kfd_process *p, uint32_t event_id); int kfd_event_page_set(struct kfd_process *p, void *kernel_address, - uint64_t size); + uint64_t size, uint64_t user_handle); + int kfd_event_create(struct file *devkfd, struct kfd_process *p, uint32_t event_type, bool auto_reset, uint32_t node_id, uint32_t *event_id, uint32_t *event_trigger_data, uint64_t *event_page_offset, uint32_t *event_slot_index); + +int kfd_event_restore(struct file *devkfd, struct kfd_process *p, + struct kfd_criu_ev_bucket *restore_ev); + +int kfd_event_dump(struct kfd_process *p, uint64_t *user_handle, + struct kfd_criu_ev_bucket *ev_buckets, uint32_t num_events); + +int kfd_get_num_events(struct kfd_process *p); int kfd_event_destroy(struct kfd_process *p, uint32_t event_id); void kfd_signal_vm_fault_event(struct kfd_dev *dev, u32 pasid, From patchwork Sat May 1 01:57:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Kuehling X-Patchwork-Id: 12234591 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=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 C6A8EC43460 for ; Sat, 1 May 2021 01:58:57 +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 947B6613F7 for ; Sat, 1 May 2021 01:58:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 947B6613F7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none 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 22D9D6F877; Sat, 1 May 2021 01:58:45 +0000 (UTC) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2078.outbound.protection.outlook.com [40.107.223.78]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1CD046F63A; Sat, 1 May 2021 01:58:40 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eeHTkRbYTZFZZq7gpqRuHM/uDrlth+bPfa7Gm40kNiMLOdgttQnMfCV68zQJIIUp7MSo+j3iwHZiuWvNJXnA2WeeKFGELj+fIOmBdhgiXSAw23LxO+idwUtoiiP5T6A21gZQdr25Yxzy1Ea1ryPg9n0fkjhjv3URaGHCTbPGgNPHdphdCirE48ZVA4tgePuGYsK2syQQAXo7NfBcZH3tf71V/gJKrtAyIQWBSMXLvRGTE/B2t74Y7LLMlUPTw774O0fSLqlMQqWjzfYgB2CrnrU0DauV9+0rc0ZBGKpZhE5xep/1gqa0h5S+5DzUcWLxLwm2frg3XLhngRRVIBXz8g== 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=bmHEtqMQAX6LZ036Gn4ezRqXKjdS02j0KGFo5s4rzkw=; b=MFJtC4u03awgq2pFwhSeDdq4WlaT5k4Z7eThBvKTACWc0fKNku/JTqw7K9eAoPczACnzm0zXX8t/MaUQcuwENTIuTmYPf4H4UMs8JP3fH2hPKmSAunsBjLSrLMXxI3uRArlDrKP5TTNr8/hC90hbEQhEQjD5nO9OMohUb0Nca1wdsagyIzoEGTiF2FzlfnhB/fLIC7d9yAVCuOPXUE3dNAEhMCUmf1TDJTM6WFWCfHFhO1K+cb+wLw6cAO1/rP6aDDP7kE/vZlCFIerD3DYmjN9ENXMW7nCiZKSi8bQLRefOJOiw4sBTDS/5b2TeJ7s7aZ7Hd9wwo1e8dS5lD1pyaA== 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=bmHEtqMQAX6LZ036Gn4ezRqXKjdS02j0KGFo5s4rzkw=; b=Tt3EA+mVZ5F7iQ/qnewy+gWfet6U0R60EtOshuhxDYob4rWvO76V91PuO0XxUmv/+teX+XDzEJny63apKOPnp3NAMAJjGnFQ0upgYJQkmbZ57DVQTUlrJg/Gy++brwhRlasE6HheamlUEmwDDOFkvTtxXQZR1Vf96YZCczCQE6Q= 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 BL0PR12MB4948.namprd12.prod.outlook.com (2603:10b6:208:1cc::20) by BL0PR12MB4932.namprd12.prod.outlook.com (2603:10b6:208:1c2::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.26; Sat, 1 May 2021 01:58:34 +0000 Received: from BL0PR12MB4948.namprd12.prod.outlook.com ([fe80::70f5:99ed:65a1:c033]) by BL0PR12MB4948.namprd12.prod.outlook.com ([fe80::70f5:99ed:65a1:c033%5]) with mapi id 15.20.4065.027; Sat, 1 May 2021 01:58:34 +0000 From: Felix Kuehling To: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [RFC PATCH 16/17] drm/amdkfd: CRIU implement gpu_id remapping Date: Fri, 30 Apr 2021 21:57:51 -0400 Message-Id: <20210501015752.888-17-Felix.Kuehling@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210501015752.888-1-Felix.Kuehling@amd.com> References: <20210501015752.888-1-Felix.Kuehling@amd.com> X-Originating-IP: [165.204.54.211] X-ClientProxiedBy: YT1PR01CA0037.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:2e::6) To BL0PR12MB4948.namprd12.prod.outlook.com (2603:10b6:208:1cc::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (165.204.54.211) by YT1PR01CA0037.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:2e::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.25 via Frontend Transport; Sat, 1 May 2021 01:58:33 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 060bc2b6-da93-496e-a04b-08d90c44a070 X-MS-TrafficTypeDiagnostic: BL0PR12MB4932: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3513; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: s3WRS6Srso9uV7X9D06L7zrZBkQ2/6BWdZEGvdcLgb4cyPnPP5lbQEN8LeX+PBgiAn1Hn3syIAzeJhjhIzej0l+ABmZldwVCEuH3jhAZFr0JiEMgz9B8WGQrDnq1LHM3vw5M1Hb08W8zZgC+qas/06EwpPikhKZp9PfJllnyR5iUjTADL6vBkr+jz+tvSPj3c+8L21xSZmjsNOQgXgxVTaE6DNTWRBivr882ZEwDgHhnr4x+JsdWP5rTK9qoDxcy8glqAGKnpvsY23mzG48GX6gW1SG/z6Vw9YCnKgR+dxJgN078R51vUmeUxyAvpKUrqyCOhSYHCfWckoeUC9Cxv0iiuk81bKoRIfyXsByTJ2ioTDz2yTD59Yw/K3PrzURUkkB0xl8kq5+Oy9+csNcdE8GhTUXhAx3Qq0XlwPk8xm37ydZB77SNHV94CwDwC8dzehCOpB/rSOnZs7NWmyIoD0Kb1Olx/IviAM8pms693xcBKfmYrZvwMmspp4CT2ysj3iMmaW3ooLZa8x0sjB+szM9SnteuHedOaRtkCOTlGetpg6X6+o3LWqlEt2Siv8J4KWEyAEiGApuUJvTwX6Js8qAuLxC1JlfwqLMQqJGVDO/oWmlmP2ryvxAb29saRGedni0spr3aK9lPFVBnVSFxrBsZkWkLnhPflG/nV1cCCPiOs5NU13FEwgBC6jsh/44s X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BL0PR12MB4948.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(39860400002)(346002)(136003)(366004)(396003)(6512007)(83380400001)(38350700002)(38100700002)(478600001)(26005)(16526019)(186003)(6486002)(86362001)(4326008)(316002)(54906003)(2616005)(956004)(450100002)(5660300002)(6666004)(66476007)(66556008)(52116002)(2906002)(6506007)(66946007)(8676002)(36756003)(8936002)(30864003)(1076003)(69590400013); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: XdLcryE7uzpXAtr8NZSuU5uiCTnerR185saBHHoUJ7nIYi2sc+AC/gkji6A+2+2/xBij+WT3ZuyehYrE28uk5/vyzAiLIDGKGdCqxafrZXoWCdd++f8Pr1RuQlYaH3sqFdj0OkgtRiUQ5SiQuZf81jc2dsxyS4ICnDVnPktZkDG3Nm+/Tj5shoaqyQb2lkgsCdwFhr3clClVkzv4ZdCPAJKm/zeOqRmaICiZBXmTb1/gGozibkn/TQuGUyeAKh5pSRjizlhRiukKk/OwYIg83NG/AvBvrTHXXBYb1KlAwcg8i3cuuyfm2UNL4wR9ng3yAMBfs+3PzOnxfYncd9b2MOgRa9DsoevllckMFlQdCAZAhYl3TsN5VxUAOhKk4YyRt+OnbfpHVeNhcqJzC087Wy48xtIK4I5i+JhFPFIpSUuf0wLxKiZw2DgQfUJcAPLV/++w97IRVUIR1yssatpFT8+Hcp6IFB1/supwT9jGqZfMwT0jWbg+gpRS0wd+t0d2cJkrTA0q6dJ/O6AtYEIp96Bw/ISOzq74XE1lW+2DE2VK+HSZ+/efVIM5btMw81BzUUjo6wT9ZXBNbIfjCe6l2qMYrBZOiMu1yeBxxuTQpVyXcMXh7OYDdobunPv7rY2GK9GoAVCyBhBO8+mRPdMgugq0EaKAtMWt5nXqrdnKRsHL7QkmCGQmyyvGSrGWZEg6zDtJT2ze03qU0LJfZZ7fGXPIxX+VcoicfP0bCJSFtSRSNtgtHaWrUDGjGSLaUhS1Vh5vByBQKkLiYV5geOT6ZpJaajrIfZx2F9uJkFsruc5NC9yu+Up5xcxe2MWKEpS4PP3s1iXZFk/KmxwS3liDZ3A4AUDPxftzJUOhCBrBEWkGCHrl8YnsjHWyEKBMjw/+uy1uwkp/Ns9YVlr9Kkd/NGBCT3xZWwJc5xuBuvtjQY4tFr95eg6VWSDggbe+fax2OcBLHRSBNg/ZVzvlhU5/FshS8xhquMWaIHCNcxyed1QzCbzWmCz3TTfjFzSqrMgegqcrUoQ4BNYZb3GgGJXk39gRI6N34nRugctxsVgZVCaOcccR8c7EHSC5PmRzs7gRfKF8lt/lSHB18d/UxQ3j7aqggxUqFKfAqCw9tSJmqFkIDJxpzAIu4UMIgAc8wPukStmw2/RzbEIAQ7YdwAE+dSvhPl2O65RRj2DSCVvq5S308OdYgVGo0feAJOTvss+GtevLmOXOAiD4C5I5T6F+rZzpRErlZuukA4bgkoOcis/Yeeu0zvKQlJYhwMl0HdjzZZ4nJodHMJJKrNea/HusIEnI2x+OxTyMmYLW0Rsv9zCcA0ETncAn0bHWJL0pGCXd X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 060bc2b6-da93-496e-a04b-08d90c44a070 X-MS-Exchange-CrossTenant-AuthSource: BL0PR12MB4948.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 May 2021 01:58:34.0184 (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: F8BWk8hW4dyRkzwSCAoCICZi3WKkU8pQspvD0Q+ZFQ8FWKDL3kBESI+T/qT8wBtPYuueLCeCxeASXEbUxYpmrg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR12MB4932 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: David Yat Sin , Rajneesh Bhardwaj Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: David Yat Sin When doing a restore on a different node, the gpu_id's on the restore node may be different. But the user space application will still refer use the original gpu_id's in the ioctl calls. Adding code to create a gpu id mapping so that kfd can determine actual gpu_id during the user ioctl's. Signed-off-by: David Yat Sin Signed-off-by: Rajneesh Bhardwaj Change-Id: I8f72afe847c9ef7b25a902b30516e9043f1b5834 --- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 245 +++++++++++++---------- drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 3 + drivers/gpu/drm/amd/amdkfd/kfd_process.c | 18 ++ 3 files changed, 157 insertions(+), 109 deletions(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c index ce511b246beb..8e92c68eb9c5 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c @@ -294,13 +294,14 @@ static int kfd_ioctl_create_queue(struct file *filep, struct kfd_process *p, return err; pr_debug("Looking for gpu id 0x%x\n", args->gpu_id); - dev = kfd_device_by_id(args->gpu_id); - if (!dev) { + + mutex_lock(&p->mutex); + pdd = kfd_process_device_data_by_id(p, args->gpu_id); + if (!pdd) { pr_debug("Could not find gpu id 0x%x\n", args->gpu_id); return -EINVAL; } - - mutex_lock(&p->mutex); + dev = pdd->dev; pdd = kfd_bind_process_to_device(dev, p); if (IS_ERR(pdd)) { @@ -491,7 +492,6 @@ static int kfd_ioctl_set_memory_policy(struct file *filep, struct kfd_process *p, void *data) { struct kfd_ioctl_set_memory_policy_args *args = data; - struct kfd_dev *dev; int err = 0; struct kfd_process_device *pdd; enum cache_policy default_policy, alternate_policy; @@ -506,13 +506,15 @@ static int kfd_ioctl_set_memory_policy(struct file *filep, return -EINVAL; } - dev = kfd_device_by_id(args->gpu_id); - if (!dev) - return -EINVAL; - mutex_lock(&p->mutex); + pdd = kfd_process_device_data_by_id(p, args->gpu_id); + if (!pdd) { + pr_debug("Could not find gpu id 0x%x\n", args->gpu_id); + err = -EINVAL; + goto out; + } - pdd = kfd_bind_process_to_device(dev, p); + pdd = kfd_bind_process_to_device(pdd->dev, p); if (IS_ERR(pdd)) { err = -ESRCH; goto out; @@ -525,7 +527,7 @@ static int kfd_ioctl_set_memory_policy(struct file *filep, (args->alternate_policy == KFD_IOC_CACHE_POLICY_COHERENT) ? cache_policy_coherent : cache_policy_noncoherent; - if (!dev->dqm->ops.set_cache_memory_policy(dev->dqm, + if (!pdd->dev->dqm->ops.set_cache_memory_policy(pdd->dev->dqm, &pdd->qpd, default_policy, alternate_policy, @@ -543,17 +545,18 @@ static int kfd_ioctl_set_trap_handler(struct file *filep, struct kfd_process *p, void *data) { struct kfd_ioctl_set_trap_handler_args *args = data; - struct kfd_dev *dev; int err = 0; struct kfd_process_device *pdd; - dev = kfd_device_by_id(args->gpu_id); - if (!dev) - return -EINVAL; - mutex_lock(&p->mutex); - pdd = kfd_bind_process_to_device(dev, p); + pdd = kfd_process_device_data_by_id(p, args->gpu_id); + if (!pdd) { + err = -EINVAL; + goto out; + } + + pdd = kfd_bind_process_to_device(pdd->dev, p); if (IS_ERR(pdd)) { err = -ESRCH; goto out; @@ -577,16 +580,20 @@ static int kfd_ioctl_dbg_register(struct file *filep, bool create_ok; long status = 0; - dev = kfd_device_by_id(args->gpu_id); - if (!dev) - return -EINVAL; + mutex_lock(&p->mutex); + pdd = kfd_process_device_data_by_id(p, args->gpu_id); + if (!pdd) { + status = -EINVAL; + goto out_unlock_p; + } + dev = pdd->dev; if (dev->device_info->asic_family == CHIP_CARRIZO) { pr_debug("kfd_ioctl_dbg_register not supported on CZ\n"); - return -EINVAL; + status = -EINVAL; + goto out_unlock_p; } - mutex_lock(&p->mutex); mutex_lock(kfd_get_dbgmgr_mutex()); /* @@ -596,7 +603,7 @@ static int kfd_ioctl_dbg_register(struct file *filep, pdd = kfd_bind_process_to_device(dev, p); if (IS_ERR(pdd)) { status = PTR_ERR(pdd); - goto out; + goto out_unlock_dbg; } if (!dev->dbgmgr) { @@ -614,8 +621,9 @@ static int kfd_ioctl_dbg_register(struct file *filep, status = -EINVAL; } -out: +out_unlock_dbg: mutex_unlock(kfd_get_dbgmgr_mutex()); +out_unlock_p: mutex_unlock(&p->mutex); return status; @@ -625,12 +633,18 @@ static int kfd_ioctl_dbg_unregister(struct file *filep, struct kfd_process *p, void *data) { struct kfd_ioctl_dbg_unregister_args *args = data; + struct kfd_process_device *pdd; struct kfd_dev *dev; long status; - dev = kfd_device_by_id(args->gpu_id); - if (!dev || !dev->dbgmgr) + mutex_lock(&p->mutex); + pdd = kfd_process_device_data_by_id(p, args->gpu_id); + if (!pdd || !pdd->dev->dbgmgr) { + mutex_unlock(&p->mutex); return -EINVAL; + } + dev = pdd->dev; + mutex_unlock(&p->mutex); if (dev->device_info->asic_family == CHIP_CARRIZO) { pr_debug("kfd_ioctl_dbg_unregister not supported on CZ\n"); @@ -664,6 +678,7 @@ static int kfd_ioctl_dbg_address_watch(struct file *filep, { struct kfd_ioctl_dbg_address_watch_args *args = data; struct kfd_dev *dev; + struct kfd_process_device *pdd; struct dbg_address_watch_info aw_info; unsigned char *args_buff; long status; @@ -673,9 +688,15 @@ static int kfd_ioctl_dbg_address_watch(struct file *filep, memset((void *) &aw_info, 0, sizeof(struct dbg_address_watch_info)); - dev = kfd_device_by_id(args->gpu_id); - if (!dev) + mutex_lock(&p->mutex); + pdd = kfd_process_device_data_by_id(p, args->gpu_id); + if (!pdd) { + mutex_unlock(&p->mutex); + pr_debug("Could not find gpu id 0x%x\n", args->gpu_id); return -EINVAL; + } + dev = pdd->dev; + mutex_unlock(&p->mutex); if (dev->device_info->asic_family == CHIP_CARRIZO) { pr_debug("kfd_ioctl_dbg_wave_control not supported on CZ\n"); @@ -764,6 +785,7 @@ static int kfd_ioctl_dbg_wave_control(struct file *filep, { struct kfd_ioctl_dbg_wave_control_args *args = data; struct kfd_dev *dev; + struct kfd_process_device *pdd; struct dbg_wave_control_info wac_info; unsigned char *args_buff; uint32_t computed_buff_size; @@ -781,9 +803,15 @@ static int kfd_ioctl_dbg_wave_control(struct file *filep, sizeof(wac_info.dbgWave_msg.MemoryVA) + sizeof(wac_info.trapId); - dev = kfd_device_by_id(args->gpu_id); - if (!dev) + mutex_lock(&p->mutex); + pdd = kfd_process_device_data_by_id(p, args->gpu_id); + if (!pdd) { + mutex_unlock(&p->mutex); + pr_debug("Could not find gpu id 0x%x\n", args->gpu_id); return -EINVAL; + } + dev = pdd->dev; + mutex_unlock(&p->mutex); if (dev->device_info->asic_family == CHIP_CARRIZO) { pr_debug("kfd_ioctl_dbg_wave_control not supported on CZ\n"); @@ -847,16 +875,19 @@ static int kfd_ioctl_get_clock_counters(struct file *filep, struct kfd_process *p, void *data) { struct kfd_ioctl_get_clock_counters_args *args = data; - struct kfd_dev *dev; + struct kfd_process_device *pdd; - dev = kfd_device_by_id(args->gpu_id); - if (dev) + mutex_lock(&p->mutex); + pdd = kfd_process_device_data_by_id(p, args->gpu_id); + if (pdd) /* Reading GPU clock counter from KGD */ - args->gpu_clock_counter = amdgpu_amdkfd_get_gpu_clock_counter(dev->kgd); + args->gpu_clock_counter = amdgpu_amdkfd_get_gpu_clock_counter(pdd->dev->kgd); else /* Node without GPU resource */ args->gpu_clock_counter = 0; + mutex_unlock(&p->mutex); + /* No access to rdtsc. Using raw monotonic time */ args->cpu_clock_counter = ktime_get_raw_ns(); args->system_clock_counter = ktime_get_boottime_ns(); @@ -1010,15 +1041,15 @@ static int kmap_event_page(struct kfd_process *p, uint64_t event_page_offset) return -EINVAL; } - kfd = kfd_device_by_id(GET_GPU_ID(event_page_offset)); - if (!kfd) { + pdd = kfd_process_device_data_by_id(p, GET_GPU_ID(event_page_offset)); + if (!pdd) { pr_err("Getting device by id failed in %s\n", __func__); return -EINVAL; } + kfd = pdd->dev; pdd = kfd_bind_process_to_device(kfd, p); if (IS_ERR(pdd)) { - mutex_unlock(&p->mutex); return PTR_ERR(pdd); } @@ -1026,8 +1057,6 @@ static int kmap_event_page(struct kfd_process *p, uint64_t event_page_offset) GET_IDR_HANDLE(event_page_offset)); if (!mem) { pr_err("Can't find BO, offset is 0x%llx\n", event_page_offset); - - mutex_unlock(&p->mutex); return -EINVAL; } @@ -1119,11 +1148,13 @@ static int kfd_ioctl_set_scratch_backing_va(struct file *filep, struct kfd_dev *dev; long err; - dev = kfd_device_by_id(args->gpu_id); - if (!dev) - return -EINVAL; - mutex_lock(&p->mutex); + pdd = kfd_process_device_data_by_id(p, args->gpu_id); + if (!pdd) { + err = -EINVAL; + goto bind_process_to_device_fail; + } + dev = pdd->dev; pdd = kfd_bind_process_to_device(dev, p); if (IS_ERR(pdd)) { @@ -1151,15 +1182,20 @@ static int kfd_ioctl_get_tile_config(struct file *filep, struct kfd_process *p, void *data) { struct kfd_ioctl_get_tile_config_args *args = data; - struct kfd_dev *dev; + struct kfd_process_device *pdd; struct tile_config config; int err = 0; - dev = kfd_device_by_id(args->gpu_id); - if (!dev) + mutex_lock(&p->mutex); + pdd = kfd_process_device_data_by_id(p, args->gpu_id); + if (!pdd) { + mutex_unlock(&p->mutex); return -EINVAL; + } + + amdgpu_amdkfd_get_tile_config(pdd->dev->kgd, &config); - amdgpu_amdkfd_get_tile_config(dev->kgd, &config); + mutex_unlock(&p->mutex); args->gb_addr_config = config.gb_addr_config; args->num_banks = config.num_banks; @@ -1194,21 +1230,15 @@ static int kfd_ioctl_acquire_vm(struct file *filep, struct kfd_process *p, { struct kfd_ioctl_acquire_vm_args *args = data; struct kfd_process_device *pdd; - struct kfd_dev *dev; struct file *drm_file; int ret; - dev = kfd_device_by_id(args->gpu_id); - if (!dev) - return -EINVAL; - drm_file = fget(args->drm_fd); if (!drm_file) return -EINVAL; mutex_lock(&p->mutex); - - pdd = kfd_get_process_device_data(dev, p); + pdd = kfd_process_device_data_by_id(p, args->gpu_id); if (!pdd) { ret = -EINVAL; goto err_unlock; @@ -1267,19 +1297,23 @@ static int kfd_ioctl_alloc_memory_of_gpu(struct file *filep, if (args->size == 0) return -EINVAL; - dev = kfd_device_by_id(args->gpu_id); - if (!dev) - return -EINVAL; + mutex_lock(&p->mutex); + pdd = kfd_process_device_data_by_id(p, args->gpu_id); + if (!pdd) { + err = -EINVAL; + goto err_unlock; + } + + dev = pdd->dev; if ((flags & KFD_IOC_ALLOC_MEM_FLAGS_PUBLIC) && (flags & KFD_IOC_ALLOC_MEM_FLAGS_VRAM) && !kfd_dev_is_large_bar(dev)) { pr_err("Alloc host visible vram on small bar is not allowed\n"); - return -EINVAL; + err = -EINVAL; + goto err_unlock; } - mutex_lock(&p->mutex); - pdd = kfd_bind_process_to_device(dev, p); if (IS_ERR(pdd)) { err = PTR_ERR(pdd); @@ -1350,17 +1384,12 @@ static int kfd_ioctl_free_memory_of_gpu(struct file *filep, struct kfd_ioctl_free_memory_of_gpu_args *args = data; struct kfd_process_device *pdd; void *mem; - struct kfd_dev *dev; int ret; uint64_t size = 0; - dev = kfd_device_by_id(GET_GPU_ID(args->handle)); - if (!dev) - return -EINVAL; - mutex_lock(&p->mutex); - pdd = kfd_get_process_device_data(dev, p); + pdd = kfd_process_device_data_by_id(p, GET_GPU_ID(args->handle)); if (!pdd) { pr_err("Process device data doesn't exist\n"); ret = -EINVAL; @@ -1374,7 +1403,7 @@ static int kfd_ioctl_free_memory_of_gpu(struct file *filep, goto err_unlock; } - ret = amdgpu_amdkfd_gpuvm_free_memory_of_gpu(dev->kgd, + ret = amdgpu_amdkfd_gpuvm_free_memory_of_gpu(pdd->dev->kgd, (struct kgd_mem *)mem, pdd->drm_priv, &size); /* If freeing the buffer failed, leave the handle in place for @@ -1397,15 +1426,11 @@ static int kfd_ioctl_map_memory_to_gpu(struct file *filep, struct kfd_ioctl_map_memory_to_gpu_args *args = data; struct kfd_process_device *pdd, *peer_pdd; void *mem; - struct kfd_dev *dev, *peer; + struct kfd_dev *dev; long err = 0; int i; uint32_t *devices_arr = NULL; - dev = kfd_device_by_id(GET_GPU_ID(args->handle)); - if (!dev) - return -EINVAL; - if (!args->n_devices) { pr_debug("Device IDs array empty\n"); return -EINVAL; @@ -1429,6 +1454,12 @@ static int kfd_ioctl_map_memory_to_gpu(struct file *filep, } mutex_lock(&p->mutex); + pdd = kfd_process_device_data_by_id(p, GET_GPU_ID(args->handle)); + if (!pdd) { + err = -EINVAL; + goto get_process_device_data_failed; + } + dev = pdd->dev; pdd = kfd_bind_process_to_device(dev, p); if (IS_ERR(pdd)) { @@ -1444,21 +1475,21 @@ static int kfd_ioctl_map_memory_to_gpu(struct file *filep, } for (i = args->n_success; i < args->n_devices; i++) { - peer = kfd_device_by_id(devices_arr[i]); - if (!peer) { + peer_pdd = kfd_process_device_data_by_id(p, devices_arr[i]); + if (!peer_pdd) { pr_debug("Getting device by id failed for 0x%x\n", devices_arr[i]); err = -EINVAL; goto get_mem_obj_from_handle_failed; } - peer_pdd = kfd_bind_process_to_device(peer, p); + peer_pdd = kfd_bind_process_to_device(peer_pdd->dev, p); if (IS_ERR(peer_pdd)) { err = PTR_ERR(peer_pdd); goto get_mem_obj_from_handle_failed; } err = amdgpu_amdkfd_gpuvm_map_memory_to_gpu( - peer->kgd, (struct kgd_mem *)mem, peer_pdd->drm_priv); + peer_pdd->dev->kgd, (struct kgd_mem *)mem, peer_pdd->drm_priv); if (err) { pr_err("Failed to map to gpu %d/%d\n", i, args->n_devices); @@ -1477,12 +1508,10 @@ static int kfd_ioctl_map_memory_to_gpu(struct file *filep, /* Flush TLBs after waiting for the page table updates to complete */ for (i = 0; i < args->n_devices; i++) { - peer = kfd_device_by_id(devices_arr[i]); - if (WARN_ON_ONCE(!peer)) - continue; - peer_pdd = kfd_get_process_device_data(peer, p); + peer_pdd = kfd_process_device_data_by_id(p, devices_arr[i]); if (WARN_ON_ONCE(!peer_pdd)) continue; + kfd_flush_tlb(peer_pdd); } @@ -1490,6 +1519,7 @@ static int kfd_ioctl_map_memory_to_gpu(struct file *filep, return err; +get_process_device_data_failed: bind_process_to_device_failed: get_mem_obj_from_handle_failed: map_memory_to_gpu_failed: @@ -1507,14 +1537,9 @@ static int kfd_ioctl_unmap_memory_from_gpu(struct file *filep, struct kfd_ioctl_unmap_memory_from_gpu_args *args = data; struct kfd_process_device *pdd, *peer_pdd; void *mem; - struct kfd_dev *dev, *peer; long err = 0; uint32_t *devices_arr = NULL, i; - dev = kfd_device_by_id(GET_GPU_ID(args->handle)); - if (!dev) - return -EINVAL; - if (!args->n_devices) { pr_debug("Device IDs array empty\n"); return -EINVAL; @@ -1538,8 +1563,7 @@ static int kfd_ioctl_unmap_memory_from_gpu(struct file *filep, } mutex_lock(&p->mutex); - - pdd = kfd_get_process_device_data(dev, p); + pdd = kfd_process_device_data_by_id(p, GET_GPU_ID(args->handle)); if (!pdd) { err = -EINVAL; goto bind_process_to_device_failed; @@ -1553,19 +1577,13 @@ static int kfd_ioctl_unmap_memory_from_gpu(struct file *filep, } for (i = args->n_success; i < args->n_devices; i++) { - peer = kfd_device_by_id(devices_arr[i]); - if (!peer) { - err = -EINVAL; - goto get_mem_obj_from_handle_failed; - } - - peer_pdd = kfd_get_process_device_data(peer, p); + peer_pdd = kfd_process_device_data_by_id(p, devices_arr[i]); if (!peer_pdd) { - err = -ENODEV; + err = -EINVAL; goto get_mem_obj_from_handle_failed; } err = amdgpu_amdkfd_gpuvm_unmap_memory_from_gpu( - peer->kgd, (struct kgd_mem *)mem, peer_pdd->drm_priv); + peer_pdd->dev->kgd, (struct kgd_mem *)mem, peer_pdd->drm_priv); if (err) { pr_err("Failed to unmap from gpu %d/%d\n", i, args->n_devices); @@ -1694,23 +1712,26 @@ static int kfd_ioctl_import_dmabuf(struct file *filep, void *mem; int r; - dev = kfd_device_by_id(args->gpu_id); - if (!dev) - return -EINVAL; + mutex_lock(&p->mutex); + pdd = kfd_process_device_data_by_id(p, args->gpu_id); + if (!pdd) { + r = -EINVAL; + goto err_unlock; + } dmabuf = dma_buf_get(args->dmabuf_fd); - if (IS_ERR(dmabuf)) - return PTR_ERR(dmabuf); - - mutex_lock(&p->mutex); + if (IS_ERR(dmabuf)) { + r = PTR_ERR(dmabuf); + goto err_unlock; + } - pdd = kfd_bind_process_to_device(dev, p); + pdd = kfd_bind_process_to_device(pdd->dev, p); if (IS_ERR(pdd)) { r = PTR_ERR(pdd); goto err_unlock; } - r = amdgpu_amdkfd_gpuvm_import_dmabuf(dev->kgd, dmabuf, + r = amdgpu_amdkfd_gpuvm_import_dmabuf(pdd->dev->kgd, dmabuf, args->va_addr, pdd->drm_priv, (struct kgd_mem **)&mem, &size, NULL); @@ -1744,13 +1765,19 @@ static int kfd_ioctl_smi_events(struct file *filep, struct kfd_process *p, void *data) { struct kfd_ioctl_smi_events_args *args = data; - struct kfd_dev *dev; + struct kfd_process_device *pdd; - dev = kfd_device_by_id(args->gpuid); - if (!dev) + mutex_lock(&p->mutex); + + pdd = kfd_process_device_data_by_id(p, args->gpuid); + if (!pdd) { + mutex_unlock(&p->mutex); return -EINVAL; + } + + mutex_unlock(&p->mutex); - return kfd_smi_event_open(dev, &args->anon_fd); + return kfd_smi_event_open(pdd->dev, &args->anon_fd); } static int kfd_ioctl_set_xnack_mode(struct file *filep, diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h index d3265860e78b..b2ea00e7309f 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h +++ b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h @@ -930,6 +930,9 @@ int kfd_process_restore_queues(struct kfd_process *p); void kfd_suspend_all_processes(void); int kfd_resume_all_processes(void); +struct kfd_process_device *kfd_process_device_data_by_id(struct kfd_process *process, + uint32_t gpu_id); + int kfd_process_device_init_vm(struct kfd_process_device *pdd, struct file *drm_file); struct kfd_process_device *kfd_bind_process_to_device(struct kfd_dev *dev, diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process.c b/drivers/gpu/drm/amd/amdkfd/kfd_process.c index bbf21395fb06..604b2b398be2 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_process.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_process.c @@ -1424,6 +1424,7 @@ struct kfd_process_device *kfd_create_process_device_data(struct kfd_dev *dev, pdd->runtime_inuse = false; pdd->vram_usage = 0; pdd->sdma_past_activity_counter = 0; + pdd->user_gpu_id = dev->id; atomic64_set(&pdd->evict_duration_counter, 0); p->pdds[p->n_pdds++] = pdd; @@ -1897,6 +1898,23 @@ void kfd_flush_tlb(struct kfd_process_device *pdd) } } +struct kfd_process_device *kfd_process_device_data_by_id(struct kfd_process *p, uint32_t gpu_id) +{ + int i; + + if (gpu_id) { + for (i = 0; i < p->n_pdds; i++) { + struct kfd_process_device *pdd = p->pdds[i]; + + if (pdd->user_gpu_id == gpu_id) + return pdd; + } + + WARN_ONCE(1, "Failed to find mapping for gpu = 0x%x\n", gpu_id); + } + return NULL; +} + #if defined(CONFIG_DEBUG_FS) int kfd_debugfs_mqds_by_process(struct seq_file *m, void *data) From patchwork Sat May 1 01:57:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Kuehling X-Patchwork-Id: 12234583 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=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 24ED2C43461 for ; Sat, 1 May 2021 01:58:52 +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 E2ED761409 for ; Sat, 1 May 2021 01:58:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E2ED761409 Authentication-Results: mail.kernel.org; dmarc=fail (p=none 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 3470D6F638; Sat, 1 May 2021 01:58:41 +0000 (UTC) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2078.outbound.protection.outlook.com [40.107.223.78]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7A9DF6F634; Sat, 1 May 2021 01:58:39 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fA5sXZYFPiCZZdP3Sw1ba+0ZWhhf8o+NTu1MLFGqIITqsIssNjT4kxFSohtR8QSaLEbVnaRkotD8vYMUrV1fa0TjszE6pWxmSImpINCUCwqGGmaeT+DvBCTWlntnErqF2VcbIzhkWTGsvt6gYEimE1xnFT0PeS9w4XNMi0ldt0u4eX+RiS/v1LAh1HN/cCjNAvLHeAveyF+WQcqugSeuJ4TkMnwWYYGRYGUpOokFPs0t+y63cjuFFVasgE/Z0yhkTYqBOkjLH7XgnwAhka++28BZJlgkyd3gZ9/b6Vc1FWZBxTTngqY9OLsypwmuAQvHLubR8dCorrnV2S0gJzqTIQ== 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=LV3/7Vy7xGW2JB7dtx6UKMz6q0cD3/LeXt9qXceFMWY=; b=meoY9mSPL5cUAOzZl3JaOu/LKvObHPyaKVq/QO96/Bqm2oTV58jO8qz8j1bycdU7XO5v5Jbqet07R4MT/CspK7hHbp//O4FuJ3zaGzJIBwgi8rI5k3BDiGH83pMMqxoDbbFyPjiEUDnc1waA0P3insZgxSto7C+gwqwuqsCMvWfIdRkZuUq/7vx+iYxwcUmDe9rnvyRgH9qLq6iZrp/Jr1+rZ3y/GVcSoo9KT0K09mAh9v420KEC4uaJlpNj5l7iI+9GHCnmsEtlLTDjRg8RA7OJaEkJpd4gZso8r1K3XtoilObhM/lGbqvWa5UNTAs4/WpTEljTmlMywWc2MP1MNQ== 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=LV3/7Vy7xGW2JB7dtx6UKMz6q0cD3/LeXt9qXceFMWY=; b=rDubAKHbkDKiDnMtuo1iWhgu9MEZ8fVWdEx/QNypvSIHZmk6cUP+HntMk4Q+AkISmYS2USHM9OCWf8Cl1uVjCIffPwbd3Keix1/XdRNH1XoKfyCf7wD5V788iT+/8YPbcTKc8rK9r9U6UUDALnRKa+wtJap3AIAgns/j1+yPayU= 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 BL0PR12MB4948.namprd12.prod.outlook.com (2603:10b6:208:1cc::20) by BL0PR12MB4932.namprd12.prod.outlook.com (2603:10b6:208:1c2::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.26; Sat, 1 May 2021 01:58:35 +0000 Received: from BL0PR12MB4948.namprd12.prod.outlook.com ([fe80::70f5:99ed:65a1:c033]) by BL0PR12MB4948.namprd12.prod.outlook.com ([fe80::70f5:99ed:65a1:c033%5]) with mapi id 15.20.4065.027; Sat, 1 May 2021 01:58:35 +0000 From: Felix Kuehling To: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [RFC PATCH 17/17] Revert "drm/amdgpu: Remove verify_access shortcut for KFD BOs" Date: Fri, 30 Apr 2021 21:57:52 -0400 Message-Id: <20210501015752.888-18-Felix.Kuehling@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210501015752.888-1-Felix.Kuehling@amd.com> References: <20210501015752.888-1-Felix.Kuehling@amd.com> X-Originating-IP: [165.204.54.211] X-ClientProxiedBy: YT1PR01CA0037.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:2e::6) To BL0PR12MB4948.namprd12.prod.outlook.com (2603:10b6:208:1cc::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (165.204.54.211) by YT1PR01CA0037.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:2e::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.25 via Frontend Transport; Sat, 1 May 2021 01:58:34 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 31138db1-9e14-4ad1-017d-08d90c44a0f1 X-MS-TrafficTypeDiagnostic: BL0PR12MB4932: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:159; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: V0bj92ns5F2fZriONlYw5iGP4wehWtix7+sIA5zlLizgrQyAa53x4hqCKQ9or0AjK5geweL78uDwIvPaFL3wnAxRMldB8AGs7Ej2Gge+TVf9DxLGgy1KFDThpjKpLUAraNaJM0N49MdFunNaVXf1QKSm9Y0nQ35nKweybRHsBRRsdlBp8F1N9KgR5lGEAA9Nyj/C4P+MrWhuqhVEPpIGO+ExkIJ9+Ox93uW2Zw+H2elwdylhVu/Tb6vtNy70ZZtJlZ3WC5ZU5GrfGqwqYqcyj+Gw/bC/TRmSCwHkPWgKiMqmuRStg7tkue8Ul+fMlTp1RvatELTJOTi3HnhHb+uHJ3KGPnJKnrvBJhK5DgwhAS2LOjaudG+JDrWoCXsgUq/TXM1Uy0wK950M0E2be+CQgpshZ6gaB7i6X85GBemn5pqxRC/663LPyYq3hZ+yyijUSvdC/HohU7UH2Rhvi9kvDC/E8uSFegGBJwODtrEHMQaduzzHol2vVnQz2HuVx465s3qYCOlWoWGnP4uCBN8zqZ7PxhKk6S2K2rs7uuh1AkftYGTQFZzu6AtAthzFKv8NhwKKxd83Jg2h6wXSqUN+cglKiBSXqLWcOpPbJhuUUbsmevyGhdKZMd/Feo5MM4II4NUtVuj+gL62/Q/dkyPhaHeRRRLfv98aWxf/gKkgTuqZ+2ETbfm5ez32m0sTZ7/D X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BL0PR12MB4948.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(39860400002)(346002)(136003)(366004)(396003)(6512007)(83380400001)(38350700002)(38100700002)(478600001)(26005)(16526019)(186003)(6486002)(86362001)(4326008)(316002)(2616005)(956004)(450100002)(5660300002)(6666004)(66476007)(66556008)(52116002)(2906002)(6506007)(66946007)(8676002)(36756003)(4744005)(8936002)(15650500001)(1076003)(69590400013); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: PTxfpg/GBFQJEvigi2pHNGJk5BzjSFVJKpaVwNKg+XEXbmFZaHA8CeL/Oj56Rhw1v+KgC93QGMAFxRMXN/Vy3mr9jBTOGk6dC0mvxn75rJk89O39BPLmMpBnZ4dXmfkEeHFmNLihgRyT/oohW8I1scFkm0Rchoc6Uif5WChdXc/DThzpmHGRsfNz4O9VKnfZ1SJ29SX09RFmajpabcoau8sSnfNlmlEXtF3mYvz+pGcN+ltiWZKNebAuXELbs/BgfzZIhmPkltLZN//C8zYHsnlQ4oV0ZhXZJAcGELdxcR+Brn+CduFdYzrzalNCtcRS30UJbZXeL5XwgK9CFuKMc4I0X6v6yn4/pMkKEey2RZpqVI6FA8/6Sfl30AkLsHszP3+nmrkQ6RKrBn8pPtvfXsw029SKjvBBU3oqivWE+dxZRagWDM2mZ+2ePV9XAGV7m42Y4S7Lfkes9yDgIEVb81AHBMVNu/bzFgVcEKKctqyPEUnvToYlcZuwCw3fZfUlNM1/Y6qBfJatrvO/HKFqyeyJMno4ZY7eV4RZG0DeFctNi+GfJG2S7+tEhBXF+9P/aznPuhPZxWyYC5Wx/1QYKxKOXGQGke6OjSJiLqT6mSGRPYXIExhAleMX3ynqdUEriJw6+9g0aigCV6i6ayM3bAubtYjClCmnT5mU+OTtz2NfW57rWrt7Gn6Uwrq3P0kaMXssg/0pMI2NdYDmaR11KpGvhOnqX86sXYHEQOXQbqqmze+y5OaAPDjxfqeqjA2pw7691IrteC6dcyHVdQtHB4JNqjAw0/xP6CauaGNmd3/hwAuQdi17KpjL3yIQ7nfJAq9ZosI41WquI8catOYbUwrjDjtwBk/JkibvCz1YcX6LKvXyf8b0ClIcN27d9EgB1Py59rJZkfQL09geEcrEM0uqhRkDF19YTYEv8TXh9FowGNJk9uyrwXlqcpbAY/88x0iKk1WeDjPMqUd2fyh7v96h6idfSV27gvfRluczjmVRIx4c1V82cUaGXJAJALSt7uSY3FUZ6It1vReH2YZDrhINIzujBfarmQtAsAO7WipAEQxQKFyy+ohMVmvzj9Jy8nFoO3GbmEHXa2QOKVBzYCpSMXvjOalvvds9JtIKQRlx19KICwg2Y/IOiNZyBElQfn7xoq2kwGweJ8ztbQBvghn17Hu5nUxNwZf7SnBNizs2+VJ1Q6iEjlVr5WIEjAjpS6JE8PqTDmo0HToh9Z4SFPpsqA7mtqtQBIug0ETWsBicMdKUT9hz/Xn6SqECj05v0nYmEAjlg2RgohlphvceSViwpaAQACYwdNiVDZjmKy8p1omcT8IdB4twt25Rg7tt X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 31138db1-9e14-4ad1-017d-08d90c44a0f1 X-MS-Exchange-CrossTenant-AuthSource: BL0PR12MB4948.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 May 2021 01:58:34.9573 (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: t8y/qaDb9UsbPycsuYqQyteWmnGOXmHtg6zsvkmtMc5g2csBI3o4t7MiR1ecjATIFWZMMu1U0FzTaubZm42b7w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR12MB4932 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: Rajneesh Bhardwaj Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Rajneesh Bhardwaj This reverts commit 12ebe2b9df192a2a8580cd9ee3e9940c116913c8. This is just a temporary work around and will be dropped later. Signed-off-by: Rajneesh Bhardwaj --- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index 99ea29fd12bd..be7eb85af066 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c @@ -178,6 +178,13 @@ static int amdgpu_verify_access(struct ttm_buffer_object *bo, struct file *filp) { struct amdgpu_bo *abo = ttm_to_amdgpu_bo(bo); + /* + * Don't verify access for KFD BOs. They don't have a GEM + * object associated with them. + */ + if (abo->kfd_bo) + return 0; + if (amdgpu_ttm_tt_get_usermm(bo->ttm)) return -EPERM; return drm_vma_node_verify_access(&abo->tbo.base.vma_node,