From patchwork Tue Jun 1 20:16:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Grodzovsky X-Patchwork-Id: 12292193 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,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 E99C9C47092 for ; Tue, 1 Jun 2021 20:17: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 B3C48613CD for ; Tue, 1 Jun 2021 20:17:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B3C48613CD Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D80C66E220; Tue, 1 Jun 2021 20:17:22 +0000 (UTC) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2084.outbound.protection.outlook.com [40.107.94.84]) by gabe.freedesktop.org (Postfix) with ESMTPS id 254246EAD8; Tue, 1 Jun 2021 20:17:21 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=K6tT7TzKB63qwC6qK4dClqXrmZIUx5lxQGnB5YlYsqO+kkBRP/uytazSRPaz4VrIra7MBmCnkN/mUTJUjwFJT5qWQ8DhhcPpTIntNFdRVLZrrK4h0pKz/5woayccof+M9/cbmK9ofgpS/sGos8nay+KsyUOrTS5wuxJlUcG1wu6Y2RXyX6gwHL1/JNnisr3VlL762zqUGsS94xEJEIyozhnZMHV6gdaSh73GSVbszWs5HdLmpFXKiGYmnze17dK9Vne+JKFT0sBKrqEpdLnVvSx9pWw6bCQB4622mHX37WPxSyBVYRlr8WhryiT0Pu+FdldOh46t7oa3yCMl4oj2AQ== 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=qZI0z8BzFFTtJeqSbs5mhjq+O4xyTOFSrNntgokBzBQ=; b=f6uVKngcEoxYrMh42E5/MbZ+79eg/YIWvDC+UVWYcipXaPRgM56qB6V2SMYNoBJRzlfm+dkef7g5EpHNDUTSXXbbpAxo10O7ezD24dn9M/Sbn5xiZB25Dhoo3vQZLGsJvm5e0e8+9Qp3SiQLUIA+Ffi4u/gpws3Sv7PU9l/c+a39ERYrJLcK7P0kun3nqe1Qbmfv93SbbjguNXemm5RTLrgidQwD3fr/Z3GlcF2eA7/WvbBW1LQ3TwJ+9ybQjNe37oN0hj6ksAimOHSa6N43vRCqU3Z5Y86Uc4rmEHnQMx4dkh/o+dgNEb7WVX91bvb4H20Cgl9OqRXXMRZdq4hGTg== 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=qZI0z8BzFFTtJeqSbs5mhjq+O4xyTOFSrNntgokBzBQ=; b=GuogSd7pBE9/D6qAF/1qHS6vNiwTTPEJ6UtvU2NhKXs0vcnO1M2XJAuV3/4mD7UUFG74pxa5aI9lf3J4hfxLLv4iuQ4UozQbayOS/tg+wiU43V/VGQKXfBwFXqC8RrJmaGsbmGjcWGDkVZDdDalhb/EwvObb/OksJdRBFX9rO4w= Authentication-Results: lists.freedesktop.org; dkim=none (message not signed) header.d=none; lists.freedesktop.org; dmarc=none action=none header.from=amd.com; Received: from SN6PR12MB4623.namprd12.prod.outlook.com (2603:10b6:805:e9::17) by SN6PR12MB2702.namprd12.prod.outlook.com (2603:10b6:805:6c::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.20; Tue, 1 Jun 2021 20:17:19 +0000 Received: from SN6PR12MB4623.namprd12.prod.outlook.com ([fe80::ad51:8c49:b171:856c]) by SN6PR12MB4623.namprd12.prod.outlook.com ([fe80::ad51:8c49:b171:856c%7]) with mapi id 15.20.4173.030; Tue, 1 Jun 2021 20:17:19 +0000 From: Andrey Grodzovsky To: dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org Subject: [PATCH 1/7] tests/amdgpu: Fix valgrind warning Date: Tue, 1 Jun 2021 16:16:56 -0400 Message-Id: <20210601201702.23316-2-andrey.grodzovsky@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210601201702.23316-1-andrey.grodzovsky@amd.com> References: <20210601201702.23316-1-andrey.grodzovsky@amd.com> X-Originating-IP: [2607:fea8:3edf:49b0:5b64:13a3:c94c:964b] X-ClientProxiedBy: YTXPR0101CA0048.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b00:1::25) To SN6PR12MB4623.namprd12.prod.outlook.com (2603:10b6:805:e9::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from agrodzovsky-All-Series.hitronhub.home (2607:fea8:3edf:49b0:5b64:13a3:c94c:964b) by YTXPR0101CA0048.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b00:1::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.24 via Frontend Transport; Tue, 1 Jun 2021 20:17:18 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fdaeb58a-6c87-445b-9f54-08d9253a41e3 X-MS-TrafficTypeDiagnostic: SN6PR12MB2702: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1303; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vWMVbsrIYowdKh1QmRai6AtpRapzsibqQYtBMIwenxpAvNwG4QJZsQTr9s7PXtFIFwzFlyQiokZ99V7wKo/F3LOrQcwi1dRWABkx9738HB6RDTtxGwl/My9h1jIMDbatc2aSW92kRVzhjMJda3h1PhFPq3NzGQaee1gjFPdM4iY/JVmrIUvWRQHFZ78yTSw0WAvSvOPNu7zQUkyB8Z+8VaUmucb/bCSCxRVzPaTOUlNNzmTJBzTcrtn/uMQDUlaQZE3aY8svVpq2vnNUrckQ6CBcmY7OSNWHkr+R5tIs/JIjrbP8O99+Gi309ZzwL9CQ/un0BUxx68Iylkg3FPNEo40tE1y4NsM0P5wyYReqwv4hwVQr2Mb0juGDI+3lRp7Yvab/yLNfHtFXML9CJkQm6Cyn1iLIdxDogN+YbJ5Tzd37HokKVLaHuKxMRG8Jdl+h5gaPLwLv96X06QLVILQjFzXPilMpJa63ckcu5+XHr5az2Yhr/srNGXS7PujibhRZXreLzoC1FxW1VYBkcHxgo+V6GPOFU17VfXJaP5ARnCw7K0hur7ixQGrNEcf4+4TwW4GnB4Lqla+fpNWamDQVe0NnzhSMoD7eAeKaYjw1rkg= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR12MB4623.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(366004)(396003)(39860400002)(136003)(346002)(16526019)(6506007)(2616005)(38100700002)(1076003)(6512007)(5660300002)(83380400001)(52116002)(478600001)(186003)(6486002)(316002)(66946007)(8936002)(8676002)(2906002)(66556008)(66476007)(4744005)(6666004)(86362001)(44832011)(36756003)(4326008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 1+/zHQr+oKDLC9001zdI/QX1L8wyipuMIcSwC/hWpwZdLtQcseQTPNYXSWlJ3iX3dVqZfsT/+5T2/6siCn+tNbrpvsMG4UZhr0TIzixrC7PF7uo66zTO1BpGqXnQkWRbjTwiA4a/UxmY6xP5B9Emw08GyMPy6ormtkfKdgTIzl4cMLEBbDqNejqSOPgeuOtKXtz9lHNGq9kzml51bmHNtQ1Gt8rg0eRcl1udTFL/l/YZwuCj741QxrV4vb6yQDc7vl6M4BIaUzNFlOpQqO+u3qRYEr4jmhFgzQ08UbBedkQfYXw1dtUmEo5MZNb+8QlRlgszK9paL9zsTkZUHIhd+AlgJnp3NVXSJ1HBF0O4QkcxZVjns+FZe+7MXvWM8sSyi9e4/hhRa57hG860KRIHf39gbz7axolG6b2UJYjXhuEEDvxNaS00RAedzY3kdyyMdQVCOmdlIdBYdTzcwgyhbr1wnqYFoxyFFxcw/nV58feVc5OrAhVbNQNzSDDIRl0vh2r3O7xPLqPe12b2OilwQNcETz/WvhtFLD1Tx0n6mXPyypDuNeUZjsJI/b/LX4tfWXNQ1Gc7n3rqBq+cUjC0EtgM8+C81cq3uwSy2qNJCLqBuX5YDWYKdb9C3AeOKG70UHWi+jcDBUi/5v71Qa86MHr5LFItWLM35EVfneR61hmveeIaE5D9P3fbGSskTfk4yTKL7VWrN4kGV3WyL1Sh5mX1OXtdIzeRF5yKrcyEMewM74zYnFEX07AdZMDp+SZ4CyYF+9FiVrMVRndXZSRUCEJwV/AjQtVlgVb7IQne96rxA6b2zJ+kURAHPMRXLC1NtLfJYgQDPs0H+SbSTYgNyCRuLW7a4DT23F/UF6DdBbA72z7HPjOV+29MyVDXjijM+Y7/F6XRkbZTukOYmh1ZPTHPtdpBaewPCi7O8NB/1AAYYMQgliZNRPgaIvXwk8JRrh0LNDMnz4qdEqJ2JDxI7XFuGqXkMNniOQj0MPV64LwKsn94dmlsaWi0mrqkuljtwChl1wo+MtF0WytENDh3Z63DjmFOZXgLNDyrLPYiHH/u2byE8qnigUM0iH6Us3mjV+Miq+Ji35TTZonINa7i74HgX+rdK3E06OOH5vCQdU5C6h0RVHysSAi3dpZbihOcxj0a0b4k/i/JGRJZUYbIuaYlrOE3o2xObby7Nu9qX7yQ+X06blxhbU7dyHJ6bUn7V7HL4ffO9RLmDSJmBZv/cuK6ty/6bufZe9VMiolnCZvDXK737V2C4qWhIgd5QCbnMSqyWpHImPM3X7amr5cAUmaXUhnAC48t1a/QrcxbsjfQ7VEUzyYvtUd6l207nsC3LUsXiytEKvw8Q/cWUIo8cZhzdLlrqE2oZzIyIsTp/DwlbfQOXtOGwP090H4oVTMZ X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: fdaeb58a-6c87-445b-9f54-08d9253a41e3 X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB4623.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jun 2021 20:17:19.7550 (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: ZRTY2aovdltbGQRUI9Ci/ZQ65sA5kwJSUc+5EwPMsohYe3tcSPhNFqPk2DP5/R+hYAvBvpReJnJAmYviibPLVA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB2702 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: Alexander.Deucher@amd.com, ckoenig.leichtzumerken@gmail.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Struct access after free Signed-off-by: Andrey Grodzovsky --- tests/amdgpu/basic_tests.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/amdgpu/basic_tests.c b/tests/amdgpu/basic_tests.c index 8e7c4916..8b7fd0f6 100644 --- a/tests/amdgpu/basic_tests.c +++ b/tests/amdgpu/basic_tests.c @@ -626,13 +626,14 @@ CU_BOOL suite_basic_tests_enable(void) &minor_version, &device_handle)) return CU_FALSE; - if (amdgpu_device_deinitialize(device_handle)) - return CU_FALSE; family_id = device_handle->info.family_id; chip_id = device_handle->info.chip_external_rev; chip_rev = device_handle->info.chip_rev; + if (amdgpu_device_deinitialize(device_handle)) + return CU_FALSE; + /* disable gfx engine basic test cases for some asics have no CPG */ if (asic_is_gfx_pipe_removed(family_id, chip_id, chip_rev)) { if (amdgpu_set_test_active("Basic Tests", From patchwork Tue Jun 1 20:16:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Grodzovsky X-Patchwork-Id: 12292195 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,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 53294C47080 for ; Tue, 1 Jun 2021 20:17: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 EEFC8613DB for ; Tue, 1 Jun 2021 20:17:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EEFC8613DB Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 94AAD6EAD9; Tue, 1 Jun 2021 20:17:24 +0000 (UTC) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2076.outbound.protection.outlook.com [40.107.223.76]) by gabe.freedesktop.org (Postfix) with ESMTPS id 59C7C6EAD8; Tue, 1 Jun 2021 20:17:23 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Znqlz5/0wwyb5hA35fM7NbQGzyfprzGg/hIipm/WrE4q0bjG61JGuy7uCRnnXQ6JBy9kc5efoKROGdnuH62TlauiJpX5S0OVS5xx5DF/Ro8bhyVeTl7vHsq8dTYOowFhxnptQJ2D4sZeP5KPO93BW2FgrajY86uvmt3YMjjIQG7M45ztVGAFWwomk8RDRU0heSyhTI2cvy8XDKqE1pa5uvsZaD2DDFNjuDe86dpU5IPaxfsAyNFBU4aYmkl45KFaqGF0KA8F7/5iS6UpEKubLmM0DlE8a+DMq/6E4Cm/nog4/1pN0WzaKBHYW3bVMH8vixNojloolYaBd2i21PFCKw== 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=I7MFCuf1zmFK8C/TNyzhF/UjAKdU4+f0JvcWVCAacEU=; b=Vqurde4BTx+6+0w10rPbRF9YaFiw3ry+Oe5TGVI/oQnf6JIR8aLdBPhw9fowEUK5uJHm0WOvdNgEmZqsd8po4OP+w7dqa5+xUehf/ErBNGGYrEsumWhGUb/Dm0iUUDnA7Z/qLfsyBY2jtId7pdPe4sGFLmUGCT4GE6clUuoOb6HC8zzmbfoZTsSaVXBZsVR963GSNMVCyd/1P3Hi1z7JG8GO+7Y9qEeUlGR28aTSjVxjf2THPNZ8oXw+PhQVOKZNGhrqe1h4ovtrR7FEGkuyvvBjFb6vyM0PESnNbS2Eqb0sqLFk9i5WzVxGaGrVT5UyNmNrdIMniIqH9IaeQGmoFQ== 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=I7MFCuf1zmFK8C/TNyzhF/UjAKdU4+f0JvcWVCAacEU=; b=qBAJ1D0jpWALhJOfN9rehj1wNNSrfos256RhFVJS2pEsGsQ7cgZSZkgbxFhja1MR975rOtOl+cu2vl8KDY/RcE0OBwxoy1R0l6Tq7RUMiRgQzvlDYn0/DkXdRCvxlNBXoUTB072c2Rq17yU8EpOQt7DOPZUyEZcFJrYyJN6BrR4= Authentication-Results: lists.freedesktop.org; dkim=none (message not signed) header.d=none; lists.freedesktop.org; dmarc=none action=none header.from=amd.com; Received: from SN6PR12MB4623.namprd12.prod.outlook.com (2603:10b6:805:e9::17) by SN6PR12MB2702.namprd12.prod.outlook.com (2603:10b6:805:6c::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.20; Tue, 1 Jun 2021 20:17:21 +0000 Received: from SN6PR12MB4623.namprd12.prod.outlook.com ([fe80::ad51:8c49:b171:856c]) by SN6PR12MB4623.namprd12.prod.outlook.com ([fe80::ad51:8c49:b171:856c%7]) with mapi id 15.20.4173.030; Tue, 1 Jun 2021 20:17:21 +0000 From: Andrey Grodzovsky To: dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org Subject: [PATCH 2/7] xf86drm: Add function to retrieve char device path Date: Tue, 1 Jun 2021 16:16:57 -0400 Message-Id: <20210601201702.23316-3-andrey.grodzovsky@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210601201702.23316-1-andrey.grodzovsky@amd.com> References: <20210601201702.23316-1-andrey.grodzovsky@amd.com> X-Originating-IP: [2607:fea8:3edf:49b0:5b64:13a3:c94c:964b] X-ClientProxiedBy: YTXPR0101CA0048.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b00:1::25) To SN6PR12MB4623.namprd12.prod.outlook.com (2603:10b6:805:e9::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from agrodzovsky-All-Series.hitronhub.home (2607:fea8:3edf:49b0:5b64:13a3:c94c:964b) by YTXPR0101CA0048.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b00:1::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.24 via Frontend Transport; Tue, 1 Jun 2021 20:17:21 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 97826204-8dbb-4aed-99d3-08d9253a4331 X-MS-TrafficTypeDiagnostic: SN6PR12MB2702: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:431; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nvfte7NeyZeDATtIlA4A0TXy6P7kcHfvBOtZoJn8uDEPMGOGdDaanoL7TOwtmhefqC4nJXyVwYo9GL0CYvJj9NO8yEFRNapYX6taU3ln1iHl7qXqLhigtPoj6HzcN5cozSvrwpTgXY1OsyhuWx1Tf1SKHmtbwWU7AW+ujsbuixFVdU2kBR9A/IS0xDqCv/XqyAoIkP2UpHeMdCEsIIY85txMgtZxCd8uWHQnIJ46h+cLaaHG6eC3jitKuFh48CX++npLgi8juDJ7lbJ2Dz35a6WbDE0U+f/aCnlmnOgrr4yUB9TpSvdD5tcJ359E3L1AUoy2Dxw/mTTNnOvNU5hOXTLi19ghChz6JZ0kwCogArYaaAm6nL4z7BCv64e1jVX0XCohH0Mzy63WHoEP+bOeTdI/Jcf637YqHhhxJ+v0krPN/z7w99xTkbicMOf5P2ptVcCGC9ZMDxykk9AVoT0Y75MU0vmQKFXYC7NeUoKJGgX4XQxL1XxU4fSbaP3VvOSgdourKxOslHvJELy1fYhbO+RlhmLPnmOr4ZhLdwS0wFKpQhcqd2xtgIdhaQ0cDjuQ3+dLDBezE8hBTttq3Fbu4eKs76BvICnR86yEXw59j7U= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR12MB4623.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(366004)(396003)(39860400002)(136003)(346002)(16526019)(6506007)(2616005)(38100700002)(1076003)(6512007)(5660300002)(83380400001)(52116002)(478600001)(186003)(6486002)(316002)(66946007)(8936002)(8676002)(2906002)(66556008)(66476007)(6666004)(86362001)(44832011)(36756003)(4326008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: aB6CWKIeVIzw/BfDyitGhWKHKdHYwWduvF7yi4OzJJyzpC5whafD7iMlnYub75v+4CC/68F+bU4VVGistlaqgFZ+lgKmn0sqQU8fUKDDtG24aVWho75NgJxh8DwfPPl4bAvSclIJUkRoB/2WzO/NxthV/wAOx50kgTSQrQdHR/7ZtkajEVnDUhqA/SEl3IotRprzAlHmnurLB5GtMDhtf+H0WcHF7GxJKBlXwF8bFii4hPFlcUNyS+zsxu55TGKwJnyMbvWVn5zUQJuGWaqFbC3YZQcWk5eI4tQ+fIFBl06bQ0HEH4KbfwtT1YleW9Orlpbol9UVRVSk8/HG5PJuiybuqgxM8rfUKbRGOX8sDKJEHKH6Nzqq3SOEud3DNpxidCBIyF12BSNmdj4mIqTZM90hBy3uIOO9iWT5oLmyRmu9+yBx/r5VQrnjKEVBN8dZpZs5HOwe5UX9ad485JRmD0Z8uccToZej8aFvdJVVMIUqu2rIbJw7eSidBA7SO3C6g/hceknOTEus3twS7vnd/yF535cyQJCw20jBfP0nLLhaPgXXNS7itVGib1cdNfO5bhnHdcnFrAZU6ZgvYgoJhcNEU/m2wYQlUZxyH11mMGD1Xea7gXs1NZ9l6TKAuIn8UdEGBdmOK6V9V/rKPoes+ZbiBYSnMNuP8tTga1ueeuI81yr8iMqxNwESuXKOcHLO5slrLQflK4zxZw5Tyjt/9LI5Yz5ks2Z6BEIZdEbSXsNx+LKOtLNbbayuowubCgpaOMSQux1MjatdioVeUEVCSAqQWBmwpR5lFnSmzy/McJmqfeXCSuubrT5erMfhZckFpDE5f4X1gLtA9BgzolslA1oJoT7M6FoS7v+yUS0uDD4IQBQPXbccfw9G8AxFe0nWdPBd6WbtMObO5xjPWVkGqt4gc9PNx0XzNy/NzePOyK9n/rv5zBxlCarA++3tnpNFMw0AdpCOny3yMTIZDQxnwCB3xKwJ2rvXjbn7oTRmhiIkZG10qmO2BTlMo56zTxF8h7PgXygmu1LDRfwiqoXbo7rEOkfhGIaGeOtmxobfJIxIrq0f9ySDc2WG0pM1JVYY3OvA5HJmc7PklsNLzFn7o/IFg1GGAjZ9+6SrD/6Us3vBxdLaBXoQ8AIkiAx8RXp6m/LLUgysE8sr+UnZ4hwCHphVYbpCzwbcapiYchfUqskb4HI87nHHKuf/RMatmdFAdJtLDPyb9WTO3g/O5BfRI4RzhP7R87yDf5IvAXMYu2huNq0dszNHTg4/zE8GV2mk0ixKc6RjGkq9WbOtHZAkGAP6K+egfwx5igSG/ztsXVVv7D8fFSgwUS3asvWJASt2PLj3qRi+Nc9VQlml/C45+JYWDmmbczmCmvu3VBEtdwKI5vEtrr4qjBXxJILHDkBG X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 97826204-8dbb-4aed-99d3-08d9253a4331 X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB4623.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jun 2021 20:17:21.6560 (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: NrLC2qbf67LnhoYsMT0+0fzAG+qOQ88V3XFfw/lQ5+1iL3Q87Y8CV0BXwJm1EPmBBPrg3odEwIxNEqlORx+BSw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB2702 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: Alexander.Deucher@amd.com, ckoenig.leichtzumerken@gmail.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Used to access device controls Signed-off-by: Andrey Grodzovsky --- xf86drm.c | 23 +++++++++++++++++++++++ xf86drm.h | 1 + 2 files changed, 24 insertions(+) diff --git a/xf86drm.c b/xf86drm.c index edfeb347..a5ecd323 100644 --- a/xf86drm.c +++ b/xf86drm.c @@ -4361,6 +4361,29 @@ drm_public char *drmGetDeviceNameFromFd2(int fd) #endif } +drm_public char *drmGetCharDeviceFromFd(int fd) +{ +#ifdef __linux__ + struct stat sbuf; + char path[PATH_MAX + 1]; + unsigned int maj, min; + + if (fstat(fd, &sbuf)) + return NULL; + + maj = major(sbuf.st_rdev); + min = minor(sbuf.st_rdev); + + if (!drmNodeIsDRM(maj, min) || !S_ISCHR(sbuf.st_mode)) + return NULL; + + snprintf(path, sizeof(path), "/sys/dev/char/%d:%d", maj, min); + return strdup(path); +#else + return NULL; +#endif +} + drm_public int drmSyncobjCreate(int fd, uint32_t flags, uint32_t *handle) { struct drm_syncobj_create args; diff --git a/xf86drm.h b/xf86drm.h index 9fc06ab8..c172dbc1 100644 --- a/xf86drm.h +++ b/xf86drm.h @@ -812,6 +812,7 @@ extern char *drmGetDeviceNameFromFd(int fd); */ extern char *drmGetDeviceNameFromFd2(int fd); extern int drmGetNodeTypeFromFd(int fd); +extern char *drmGetCharDeviceFromFd(int fd); /* Convert between GEM handles and DMA-BUF file descriptors. * From patchwork Tue Jun 1 20:16:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Grodzovsky X-Patchwork-Id: 12292197 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,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 3D27EC47080 for ; Tue, 1 Jun 2021 20:17:34 +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 0C12E613DB for ; Tue, 1 Jun 2021 20:17:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0C12E613DB Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 41CA36EADF; Tue, 1 Jun 2021 20:17:26 +0000 (UTC) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2043.outbound.protection.outlook.com [40.107.94.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id 81E1C6EB03; Tue, 1 Jun 2021 20:17:24 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BDyuRx7H/Y2rsd3vV8OxHBBViFi9/O7lWTq+JhZy2h0F4SBLPuVFA9YevdySk7o1YSx1uOlSPiUA/1U3XfmFelFdUn+8N5nf242gam1vf2PEle7Z4WTlCm+IQ/g4L3OUM/sWcBkaeV142CoE7ocH52b54AkYpOM43iVTMkBtutWVMi6zd0cmmqD2o/WY4+/z634fUeshHo13+ag8Q/+R2rzePcSGnr/+piJ5nnViG6dgSk+SA8XRahH+Xi8oDsr8AKp1Q6MqCwxk4TdpFxCJ1SSQdvdY05solY7azCvoE98jZvJ/5IdkZUGLiwyH4pW2hHnYhOB8L2YpaNKup/aNAQ== 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=U8GWePhC9ioBhzvmoZWFvdWcZ1henrPcTa+uaVi1tY4=; b=eOBhlreKZTk7/ElHMbfXkkU5z+HwFnmgorbM4w81dkROUgzq50RsrK7A5iSmR7Nyiddbx6bMdGtfEoQ4SiGkVCk1QWjs9IcHscOLb8EYno5oVJEl0mEvndnalHpR5UugMMIsnvZuiNOJolcjYom3ugjb6GCxVl5Bdfq/rBKEaxIPjQqbgfVq1l8zDe67VJUrb0EdhLgok7jcHEEgzQwMiGg7H7CsbX2TSt5n9pKHY9687JrL1NCP0bHMh8BY9JxjAyP1EpKHHjQuxL/BGIqQPJBd9qEjl0X467VjQ3M7ULfl4Ms7/Degi7vzGk4WTp1ybU9cUnsxzqpRBAhzT68KSg== 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=U8GWePhC9ioBhzvmoZWFvdWcZ1henrPcTa+uaVi1tY4=; b=gSXYKBDYxfv/HMSkctnrjws8aC9BC9EjNW3Z+w11O/Wj+j8HQ3KuIRoxPCXHDbNydBUIPuD3PSZ+rO7nY9kv8jupGfGlwAJUH7jktlH8M1wZw4t9hrAYv25yQdw+pBqxM6MzdVBBTAPvSvE6f9/NIxV42KN8EJbwz6d1Ekkzqwc= Authentication-Results: lists.freedesktop.org; dkim=none (message not signed) header.d=none; lists.freedesktop.org; dmarc=none action=none header.from=amd.com; Received: from SN6PR12MB4623.namprd12.prod.outlook.com (2603:10b6:805:e9::17) by SN6PR12MB2702.namprd12.prod.outlook.com (2603:10b6:805:6c::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.20; Tue, 1 Jun 2021 20:17:23 +0000 Received: from SN6PR12MB4623.namprd12.prod.outlook.com ([fe80::ad51:8c49:b171:856c]) by SN6PR12MB4623.namprd12.prod.outlook.com ([fe80::ad51:8c49:b171:856c%7]) with mapi id 15.20.4173.030; Tue, 1 Jun 2021 20:17:23 +0000 From: Andrey Grodzovsky To: dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org Subject: [PATCH 3/7] test/amdgpu: Add helper functions for hot unplug Date: Tue, 1 Jun 2021 16:16:58 -0400 Message-Id: <20210601201702.23316-4-andrey.grodzovsky@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210601201702.23316-1-andrey.grodzovsky@amd.com> References: <20210601201702.23316-1-andrey.grodzovsky@amd.com> X-Originating-IP: [2607:fea8:3edf:49b0:5b64:13a3:c94c:964b] X-ClientProxiedBy: YTXPR0101CA0048.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b00:1::25) To SN6PR12MB4623.namprd12.prod.outlook.com (2603:10b6:805:e9::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from agrodzovsky-All-Series.hitronhub.home (2607:fea8:3edf:49b0:5b64:13a3:c94c:964b) by YTXPR0101CA0048.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b00:1::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.24 via Frontend Transport; Tue, 1 Jun 2021 20:17:22 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 45d1b68c-220a-4095-f73c-08d9253a440d X-MS-TrafficTypeDiagnostic: SN6PR12MB2702: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hE62sgBnNXTixygBdZaPK87Zx2llHFuaRq1KKZsK8KrqWdzt/RP9f4zcgv0ErhL4/srNHKvkiK0GbHOBwQp8VidInnsSGEwa4Yq2EkOW/RBnq/EnJyc/6T0VvcwMHs0K4dCHsJxDsRmxur0DDeeutChTOkMzX0zEssepcm/JyZUm/sIwZZFC800Z2d0ZpdJ/jmthHUegLS6KY8PTy4PmxemaiX+VCAH8b1FfW2VaQhm966txS/6nEWsPSEWEga96Lf8rQfYKyZMWYahunNSAn08MBKkWqbj2kOTfHDzZVKwGSXFKrroL054ik1OVMsnF7j/BYER0tfmWrBeFiaQr9djmj+uYT/BmpqiGlEuApiyXKaSPbCVylqkFVb/ZprcqTjFbzjn7MQdBg5wHXWyIpoWwLOgVdw9Sx4uRpC+4gVBLuzXrvnUYXHrL0YZXCSV49XCj7+31lxzlWSDkZNB+2Y8txQLpIpQ+3p9iWSuRHG2rakrpXpVf87fGV4aBbGaposKevh+ktOAndCSxSNbN4eQYULNRz/YVC6AE9K/32k1fwo+NyBawF9m2O9Uv5S/5cKylu5t4CN2zX9e2FESlZPsUlHpAErcMFhhce4wCxPI= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR12MB4623.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(366004)(396003)(39860400002)(136003)(346002)(16526019)(6506007)(2616005)(38100700002)(1076003)(6512007)(5660300002)(83380400001)(52116002)(478600001)(186003)(6486002)(316002)(66946007)(8936002)(8676002)(2906002)(66556008)(66476007)(6666004)(86362001)(44832011)(36756003)(4326008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: R7eSsNKBI/PhK3TIJkKHC2qQIncAe1bb9vwTr4hwnuiij8rGFp1JV+vdadLI/IYPshAkRPml+ZJFYdGgcmFPaLdS9GMt0zqgY9Nssi7+Hj09pvQaLrfMwZxk53srBKM1cZloIQYTIGUEbFz57hNMYHM/QuQ1Nz8EEkzuyBhonYhQ2EDn0yZ9rzqUOBfSIdel/vECN/59QVIW2bCDkTSzoUbxIoa1GzisWrwttzKnjdpUoO/BzhElPqQVkr8/5ThHEjMt34Z9TZT2/MUrUHzEUtQfatqN0xU/ENJmABqrru7vjk4XNXNfJwV/vDH1W41Cyqn+i93wNEv+JU7H6hImOyNbY4q0KrqjMnuvylMopayAtf9YecCqoHsGX12+QCsWJbO8O2z33D9959fN1Nk1AJbIjKVdDmu9NIPLA3l2pJSJNNV6oQdb4NWTpn8h3jLZHMRpo0KuF0WCJI0Tpj9hb+jxPxkcIB30HX23bkjJz+BMXjj2dKrO0hmU8MtTsK9v1Y4YK3bRcfJaTOKvgeQodAUM2wwW6ZNCRA5wFY9aMnLyxa3H6zG+PY7nbsIerT3GZKCikOanjLYHQjRrPD6RMIyIVMzMo9wx7nMyJqOPw/zpPCsx3odDRzgInSsMfJeDZTbizGtMN7HI4Ec602NaSos3PHxE8XDicSKAFLb7DTgW0YAPmLvD8Wiz5iM821/tI1be1r3D+3l23ETdNl5jof1SAiRZH78iq9uy6CvFOm6HRh/TCljEowNEpGogtOwd1Z/JfSTHSynkv/zLmP9944B6p85Gb9qzTrfyX/qrNP0DivtxejRZpu4k/lnoMOdeQQzBo5LUsYfia2t9EJuUyC1oTDpHWQwd2j6kiYtgTNUw8rEYDSJGhwkslIS+/T7ntDUiiG/ho3F+gTWhX/GCZ0gZZRwKnjXd34TPkgH1NIl3ySIip8SG7W7PhOU0B85oj+ZmjlhzY+2C4OueOieMJ6XfLkf5icnDtImKgRxhr6z4j/9tZvX6y4BRa/aRa6sNIBVXpx7tpT6shw/IjCE4KD1Ns6Y5u46/i076ceSmHjt71AwdeFeR0tVRJGR5VIDMHCPWLUHpGa0P4QpOHInBp2BOwBr/2mezgXdV8EDuPLVB9WTL5zKw64jmKu2yyyKT69mf4JP4T6/kxoQ7OPeCP8LCsItSpwkA0MrnWQfCpzucPgKAhffeCNzMa4Dcv7Pr2qb1qbTTOXrxRQfqRdGRHhFnqt+E4C1qBDgF8uG2glJ4v1cYt/9rQMOJLuIDSLZvuVLalJIt0squhB6ShcGeu2MumVcHxv2pvpEc/CTst8GTBmp8xdAfZubNJDwlt/KMmvz7srXA97YBfLN8m5OcmlzOjFr5mgPu49K4y3qSuiHU3+SK9BjfbAWx4w+uiVUE X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 45d1b68c-220a-4095-f73c-08d9253a440d X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB4623.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jun 2021 20:17:23.2291 (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: QbtpkqhXRjHmdF9Zi6qKs5liwIsMupCBSxZiNxZXhq0pR2MU9dsAUagDUijpEi0qYRqdru/1N8dXhcsC6KjFVA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB2702 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: Alexander.Deucher@amd.com, ckoenig.leichtzumerken@gmail.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Expose close device and add open device wich preserves test index. Signed-off-by: Andrey Grodzovsky --- tests/amdgpu/amdgpu_test.c | 31 ++++++++++++++++++++++++++++--- tests/amdgpu/amdgpu_test.h | 3 +++ 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/tests/amdgpu/amdgpu_test.c b/tests/amdgpu/amdgpu_test.c index 60f3a508..2864eaff 100644 --- a/tests/amdgpu/amdgpu_test.c +++ b/tests/amdgpu/amdgpu_test.c @@ -339,12 +339,13 @@ static int amdgpu_open_devices(int open_render_node) /* Close AMD devices. */ -static void amdgpu_close_devices() +void amdgpu_close_devices() { int i; for (i = 0; i < MAX_CARDS_SUPPORTED; i++) - if (drm_amdgpu[i] >=0) + if (drm_amdgpu[i] >=0) { close(drm_amdgpu[i]); + } } /* Print AMD devices information */ @@ -520,6 +521,31 @@ static void amdgpu_disable_suites() fprintf(stderr, "test deactivation failed - %s\n", CU_get_error_msg()); } +int test_device_index; + +int amdgpu_open_device_on_test_index(int render_node) +{ + int i; + + if (amdgpu_open_devices(open_render_node) <= 0) { + perror("Cannot open AMDGPU device"); + return -1; + } + + if (test_device_index >= 0) { + /* Most tests run on device of drm_amdgpu[0]. + * Swap the chosen device to drm_amdgpu[0]. + */ + i = drm_amdgpu[0]; + drm_amdgpu[0] = drm_amdgpu[test_device_index]; + drm_amdgpu[test_device_index] = i; + } + + return 0; + + +} + /* The main() function for setting up and running the tests. * Returns a CUE_SUCCESS on successful running, another * CUnit error code on failure. @@ -535,7 +561,6 @@ int main(int argc, char **argv) int display_devices = 0;/* By default not to display devices' info */ CU_pSuite pSuite = NULL; CU_pTest pTest = NULL; - int test_device_index; int display_list = 0; int force_run = 0; diff --git a/tests/amdgpu/amdgpu_test.h b/tests/amdgpu/amdgpu_test.h index 4970d0dd..107134a5 100644 --- a/tests/amdgpu/amdgpu_test.h +++ b/tests/amdgpu/amdgpu_test.h @@ -476,4 +476,7 @@ void amdgpu_test_exec_cs_helper_raw(amdgpu_device_handle device_handle, struct amdgpu_cs_request *ibs_request, bool secure); +void amdgpu_close_devices(); +int amdgpu_open_device_on_test_index(int render_node); + #endif /* #ifdef _AMDGPU_TEST_H_ */ From patchwork Tue Jun 1 20:16:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Grodzovsky X-Patchwork-Id: 12292199 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,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 09E10C47093 for ; Tue, 1 Jun 2021 20:17: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 C9214613CD for ; Tue, 1 Jun 2021 20:17:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C9214613CD Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EF25F6EB04; Tue, 1 Jun 2021 20:17:27 +0000 (UTC) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2086.outbound.protection.outlook.com [40.107.94.86]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8E7586EAE1; Tue, 1 Jun 2021 20:17:26 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nKCDSvbTAQTS5p9FsWP+t28bm4t5LguTxUAJO1TUTPL22ReeHlYwMZ9WOtF+7uac9DF1DoJFkpVd8KgUaiFKaIiQ2iKF1rtnXGLr/5J4KD66ewzPdTwfT1jAwso385vfwLGyN4fn/slzyNFKSsQxpZTgbNs3rktzJVBpfTV3dYWRMns8aIX8ipmEx2E3G9J0hWHt7e+6sVqKkFNj6HWwP5ZhJbIift1UpTgCqjM85FHtIADAqHiJcPytxZ6pa94RO7zpdDdFUdAC10CbcRsVDN0b2cC25hc4PrpBx+UOCDkThLuoPXOA+EBfOzB9rgKCiw49HoGjPsZ/Fp3/m8wh/A== 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=luXjnD5F/aDMqOHZAWN0qrITdbLhAKDopog/EgzqkcQ=; b=AtN9o3sc9ugauMbv+J+wQTx2SMox5s+6vZzZiY9VjRfFgVUZqCzUwIZSGCWjg4G45WLrIUmh9/GYsyuymES8Hnm89DoHJ563kdEq50jRc2qhMjJJj2sYBcmGY/I3ovstWLuJaxjCDGeFHhnB+uoavFb3CVd2UPn++uwlVotdrjR6vQJWdqulXeM92GxS2y99sGttVmTXnA848iv95LwSQaGt4RiXkWSoq0A4vhBVlW58XXmtowOhN7En+KQYwg8whPM+XoNZpxAayNOrzmOBImEt+xkEVT9JQpaZTlqaUzALmLFXIakfKc5DEKBkdHmktHUkUr9UA1izSsbk/gGTsg== 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=luXjnD5F/aDMqOHZAWN0qrITdbLhAKDopog/EgzqkcQ=; b=uAahFHI2QDlsuVEUwLWPK33LAPPDfGlYz4iL+N8xg83Vb0hkrL3jrhVnAs+C2vbzj4QbWXbqiscqYHcRtOrky2iQs3hQPVhNLZVob0+O0MD3h4iJD4SE/jXHU/csDeQ2dEwaCKI2WEVLosFof7lYRJv7sfrvC3wfz29TtvwHZhI= Authentication-Results: lists.freedesktop.org; dkim=none (message not signed) header.d=none; lists.freedesktop.org; dmarc=none action=none header.from=amd.com; Received: from SN6PR12MB4623.namprd12.prod.outlook.com (2603:10b6:805:e9::17) by SN6PR12MB2702.namprd12.prod.outlook.com (2603:10b6:805:6c::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.20; Tue, 1 Jun 2021 20:17:24 +0000 Received: from SN6PR12MB4623.namprd12.prod.outlook.com ([fe80::ad51:8c49:b171:856c]) by SN6PR12MB4623.namprd12.prod.outlook.com ([fe80::ad51:8c49:b171:856c%7]) with mapi id 15.20.4173.030; Tue, 1 Jun 2021 20:17:24 +0000 From: Andrey Grodzovsky To: dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org Subject: [PATCH 4/7] test/amdgpu/hotunplug: Add test suite for GPU unplug Date: Tue, 1 Jun 2021 16:16:59 -0400 Message-Id: <20210601201702.23316-5-andrey.grodzovsky@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210601201702.23316-1-andrey.grodzovsky@amd.com> References: <20210601201702.23316-1-andrey.grodzovsky@amd.com> X-Originating-IP: [2607:fea8:3edf:49b0:5b64:13a3:c94c:964b] X-ClientProxiedBy: YTXPR0101CA0048.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b00:1::25) To SN6PR12MB4623.namprd12.prod.outlook.com (2603:10b6:805:e9::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from agrodzovsky-All-Series.hitronhub.home (2607:fea8:3edf:49b0:5b64:13a3:c94c:964b) by YTXPR0101CA0048.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b00:1::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.24 via Frontend Transport; Tue, 1 Jun 2021 20:17:23 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ebed0baa-0506-40af-30d3-08d9253a44fa X-MS-TrafficTypeDiagnostic: SN6PR12MB2702: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2PyjCp6uoyJFG3sU7FgFhA8PGOY+AVw0b7R2FD6W1hrtyvk79DiIgZOhdMRTTBMn3NVbw7R3th61T20a6mnsF+6kjlz6oeE/epz1ihaz/Y0n866FP0ym/PBrjuC5YZXRaZ7aB+yWWI7XTBXIiEyVaSHV1y8wC/vAyPAws7aVgvWDOtfQpPHbwvRJ/u+xt2OxbA0I+/fQw6SCWRiCvOXS1Wy7y9cpFsSBZY131Mv3Y5Hkj3cCQZav5Tq2bu6YHQOAejssV2DtssAl/XHEk4i1NqEwXZR4BV0VJvVEeKMAkNIQcs+4wFwdJbNeShKA3WUBvXp5iHRXB9eXFQMjLqRJFmxIRpSO8j8ymRGP2qI/OB9upsZgHTrCMde5z+Q9UVRkw2ji+a8dIpSf77qYKuquN0A30bDpguNmXZ3ksPXA7TecSy2q4OCGhsoX5y9g5QmUMQ9I3hdvsXVQvK733V9kOPnjj+TWPpWheQGZnRxA3SpB1Qo8bt0Mq0HlpfjipVgNoX0WpXnfXiAZxeXKLUmrFfB5jwv3VmdWlGqYZrq0saxzuZChf24Bh7x6FuUDFDvDVJ6lc2Nox2NkK1O6a9ysKh2ON/GfFT55Z+TKiWvkvJs= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR12MB4623.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(366004)(396003)(39860400002)(136003)(346002)(16526019)(6506007)(2616005)(38100700002)(1076003)(6512007)(5660300002)(83380400001)(52116002)(478600001)(186003)(6486002)(316002)(66946007)(8936002)(8676002)(2906002)(66556008)(66476007)(6666004)(86362001)(44832011)(36756003)(4326008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: Zon+cTb47LTBBqJLt5MCc0c18u+93FQ2cJjM+Co2eF46EnfFruwePxR595PmQTcZE+IR60naqkZCpD+aa5wJhU6scfQsN/5SYDMeZCIdpIvbpmQY8n+2sHxWQ7xyBrU325xYYhGlXQQU8hPixNxDxx59qjGAUO5r99uM9YudJo1r8Uv+WrV4LMnoGRpW+3W+nVmIVuD1S0cfXYql9kyqINW8vkwXhGG7zcZbwzoxPAOTTbBeXRcnaHquCVASyACwlwY9ttF+UJLds/vtsVQ4eiFGceUOG8QzYUe7MY075xGQDQw4soRPnOeLodkaWYuxTVW+5pvwSNc5PrfNjSi9Hjq16SoGbCZBBgfPaIldrzoAeUIBcy8c34xgRWzjLtIaS7DWAG/CBGJlw+MmfXhzwC4tL7jMpb+Gw/mh3R2K/sN9hXezHAbeqt0RIobtdB0wKpbV/ecTx6L2siIhBXfA1/3WeDsH57iMJERMcmIwHwoFDO21lLFYrSv9CGZd8meG3V4D4Dw+YlAHdVteNg8DZqlUTkcjmFx6WKj52+Ym+wEOOu4Ta4VJDGC9K9QOkxJgqJvITcZaTAvhwarRPxSYeTEutKi4fbyeFcuEOYnRXt2vWi/uEkC6nPoat7Urxkv8/CdCjyXkyXQ8NaZQ3dE96vmGwKr45yVXbtwFuuAFvk+BTMTBtU+RP3fnKjAyDXIiyWuVu8UBDkCvjH1KaS0llcF1wyG9UH4O+TlcDVFhNJZ7Y1WsEKtx90Bp3L9HiozqFTssTnyS39S/NztzENjKgTZhNYlCDXk/nd402XTGq8HzzChF6y4QsEC6NQUh8ejJNHhqWJfyQ37EHyA6HRTAp8oWaTgJuTOqVzHJenyq8PKJCa8OZXtWFg9fu2EBqB8ytli1zwT90uI6aFeOJ7G653FaAFJ7ubzM/0NvWaEejQDxOkDN2DSNmzv/wFDIxvvJL/OdL8JPD3qSNdUZRd5Xl4zUzzz253KwZ/arpsKjVdYMsjMsmn/VCqCWlXFuOI3j51woHD8PRQD4NyFQHXxkW07X+tGmdZLkaMhra9Bce24symVuaf+dXA52+Moz4a58+bmJ+hDMvhHGz1S2/JFzbtDUJH8JG9KnzSIaIB5JWwcHZ9mhhkHt8+36Duk5dWPeLBK6c30l1dXNduLYdGfpNgshHs6sx9MnDdH8kCYG3tONTieIpnZ34cmzCVnxHtdHda1UXbqju7UaclTbLUMQmycW0hn94vSIjMQRlt+zGdvhp4sZEAEIQspOjPzhZ2tmlbp8xovQyvVPAaKcG/NUdBKupYQqUmCkBmvuGdqtWhfqBlDJd1id3KIlGX0HLvPxKd44Yy5hBae4EE8/lCrEXwfYwjH7i3/GxNrnYr0/tJMUpgPlrz/6VByS+Q3DmBVW X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: ebed0baa-0506-40af-30d3-08d9253a44fa X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB4623.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jun 2021 20:17:24.7772 (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: h8OX0NQjYKkzIfM69nS4XgHET9E3D3wDC+qZiId4DMv2buCzXI+t2p6htrNrX3YHzIfp0ifI5onML1/zcoFNKw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB2702 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: Alexander.Deucher@amd.com, ckoenig.leichtzumerken@gmail.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Add just the test suite skeleton. Signed-off-by: Andrey Grodzovsky --- tests/amdgpu/amdgpu_test.c | 11 ++++ tests/amdgpu/amdgpu_test.h | 23 +++++++ tests/amdgpu/hotunplug_tests.c | 116 +++++++++++++++++++++++++++++++++ tests/amdgpu/meson.build | 1 + 4 files changed, 151 insertions(+) create mode 100644 tests/amdgpu/hotunplug_tests.c diff --git a/tests/amdgpu/amdgpu_test.c b/tests/amdgpu/amdgpu_test.c index 2864eaff..a10a031a 100644 --- a/tests/amdgpu/amdgpu_test.c +++ b/tests/amdgpu/amdgpu_test.c @@ -59,6 +59,7 @@ #define RAS_TESTS_STR "RAS Tests" #define SYNCOBJ_TIMELINE_TESTS_STR "SYNCOBJ TIMELINE Tests" #define SECURITY_TESTS_STR "Security Tests" +#define HOTUNPLUG_TESTS_STR "Hotunplug Tests" /** * Open handles for amdgpu devices @@ -137,6 +138,12 @@ static CU_SuiteInfo suites[] = { .pCleanupFunc = suite_security_tests_clean, .pTests = security_tests, }, + { + .pName = HOTUNPLUG_TESTS_STR, + .pInitFunc = suite_hotunplug_tests_init, + .pCleanupFunc = suite_hotunplug_tests_clean, + .pTests = hotunplug_tests, + }, CU_SUITE_INFO_NULL, }; @@ -198,6 +205,10 @@ static Suites_Active_Status suites_active_stat[] = { .pName = SECURITY_TESTS_STR, .pActive = suite_security_tests_enable, }, + { + .pName = HOTUNPLUG_TESTS_STR, + .pActive = suite_hotunplug_tests_enable, + }, }; diff --git a/tests/amdgpu/amdgpu_test.h b/tests/amdgpu/amdgpu_test.h index 107134a5..e2e35fec 100644 --- a/tests/amdgpu/amdgpu_test.h +++ b/tests/amdgpu/amdgpu_test.h @@ -273,6 +273,29 @@ amdgpu_command_submission_write_linear_helper_with_secure(amdgpu_device_handle unsigned ip_type, bool secure); + + +/** + * Initialize hotunplug test suite + */ +int suite_hotunplug_tests_init(); + +/** + * Deinitialize hotunplug test suite + */ +int suite_hotunplug_tests_clean(); + +/** + * Decide if the suite is enabled by default or not. + */ +CU_BOOL suite_hotunplug_tests_enable(void); + +/** + * Tests in uvd enc test suite + */ +extern CU_TestInfo hotunplug_tests[]; + + /** * Helper functions */ diff --git a/tests/amdgpu/hotunplug_tests.c b/tests/amdgpu/hotunplug_tests.c new file mode 100644 index 00000000..9d11dae4 --- /dev/null +++ b/tests/amdgpu/hotunplug_tests.c @@ -0,0 +1,116 @@ +/* + * Copyright 2021 Advanced Micro Devices, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * +*/ + +#include +#include +#include +#if HAVE_ALLOCA_H +# include +#endif + +#include "CUnit/Basic.h" + +#include "amdgpu_test.h" +#include "amdgpu_drm.h" +#include "amdgpu_internal.h" + +#include + + +static amdgpu_device_handle device_handle; +static uint32_t major_version; +static uint32_t minor_version; + +static uint32_t family_id; +static uint32_t chip_rev; +static uint32_t chip_id; + +CU_BOOL suite_hotunplug_tests_enable(void) +{ + CU_BOOL enable = CU_TRUE; + + if (amdgpu_device_initialize(drm_amdgpu[0], &major_version, + &minor_version, &device_handle)) + return CU_FALSE; + + family_id = device_handle->info.family_id; + chip_id = device_handle->info.chip_external_rev; + chip_rev = device_handle->info.chip_rev; + + /* + * Only enable for ASICs supporting GPU reset and for which it's enabled + * by default (currently GFX8/9 dGPUS) + */ + if (family_id != AMDGPU_FAMILY_VI && + family_id != AMDGPU_FAMILY_AI && + family_id != AMDGPU_FAMILY_CI) { + printf("\n\nGPU reset is not enabled for the ASIC, hotunplug suite disabled\n"); + enable = CU_FALSE; + } + + if (amdgpu_device_deinitialize(device_handle)) + return CU_FALSE; + + return enable; +} + +int suite_hotunplug_tests_init(void) +{ + int r; + + r = amdgpu_device_initialize(drm_amdgpu[0], &major_version, + &minor_version, &device_handle); + + if (r) { + if ((r == -EACCES) && (errno == EACCES)) + printf("\n\nError:%s. " + "Hint:Try to run this test program as root.", + strerror(errno)); + return CUE_SINIT_FAILED; + } + + return CUE_SUCCESS; +} + +int suite_hotunplug_tests_clean(void) +{ + int r = amdgpu_device_deinitialize(device_handle); + + if (r == 0) + return CUE_SUCCESS; + else + return CUE_SCLEAN_FAILED; +} + + +static void amdgpu_hotunplug_gfx(void) +{ + printf("Hello!\n"); +} + +CU_TestInfo hotunplug_tests[] = { + { "gfx ring block test (set amdgpu.lockup_timeout=50)", amdgpu_hotunplug_gfx }, + CU_TEST_INFO_NULL, +}; + + diff --git a/tests/amdgpu/meson.build b/tests/amdgpu/meson.build index eb16a50c..e6e30812 100644 --- a/tests/amdgpu/meson.build +++ b/tests/amdgpu/meson.build @@ -25,6 +25,7 @@ if dep_cunit.found() 'amdgpu_test.c', 'basic_tests.c', 'bo_tests.c', 'cs_tests.c', 'vce_tests.c', 'uvd_enc_tests.c', 'vcn_tests.c', 'deadlock_tests.c', 'vm_tests.c', 'ras_tests.c', 'syncobj_tests.c', 'security_tests.c', + 'hotunplug_tests.c' ), dependencies : [dep_cunit, dep_threads, dep_atomic_ops], include_directories : [inc_root, inc_drm, include_directories('../../amdgpu')], From patchwork Tue Jun 1 20:17:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Grodzovsky X-Patchwork-Id: 12292201 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,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 D98F5C47080 for ; Tue, 1 Jun 2021 20:17:38 +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 A130E613D6 for ; Tue, 1 Jun 2021 20:17:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A130E613D6 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3A0F06EB08; Tue, 1 Jun 2021 20:17:29 +0000 (UTC) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2087.outbound.protection.outlook.com [40.107.94.87]) by gabe.freedesktop.org (Postfix) with ESMTPS id C4E4F6EAE2; Tue, 1 Jun 2021 20:17:27 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Hh/yLdDC/xyuky4l0jVXNlrPdl6PLBGMSTCHzCvXWUxPvolKQ15cClX43xVmcU003kow4GuAjLPj1V7JLVt9J4Q/pdknnrbVRI8UEnkc0UKjmCMdLLxsI5tlxtlwExU/BMbmK6m6W8qqAncJFLIU1RS7MSXcTooRcK/KFpSF6sDNS1TuOeMHOwrPPdw/L1dRU5ErEoxOdzNerZan4+Gz6QOQyDyQ14nJ3+iOL7bweDf2+3Lz2IlmSDM0f4gRZAJMNSL+63Vxri9z4o3uXeDG9vHtpqo+M+U5xZ0bWmIawIQfNW2BqbxMo9BzpAqzd9oVBGYKYf6BF4hgbuiB/lpQHQ== 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=6iQhP4nRjpQD/qYKvZwANUDp4dzNJyRYmbfuEz9rFL4=; b=Or2xE6FoffmmDqSORmd/aqYYVQFqeMC7/9eHNtayMUmSe2VHrDPD0gu4rjFMnxstvoiB5sgLgxUTlERWQBUuYPuRkvEp/PH6B7ptqSx0s1nt5DUOIZP7mBRFAO07gZ+mxSRDQxyFCNk6qnTfD8z6Qm5voPADyXBqC4xSQx/NRQj1QBu6zhz5qtWL/fbdQKSiG1ktHqNEBmZDkL9ZPcUkbSLF9WCH8fwpNGhsiRlc7GIrd0INdLbOh2SB32yr1VWHC2ZGmm3cQ2qumG99TTM/xN+0oPisZWM5LMDUtRScw+gbZcPCGvrDsUrN7O0GxYAY+nm74McPEoYGblPF6yxYaQ== 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=6iQhP4nRjpQD/qYKvZwANUDp4dzNJyRYmbfuEz9rFL4=; b=keq33Jmq7WfiVbnHhOw/oBPQoVb4my4W+yfBXNDz7FOwdfJpc/2md7vlakzYgP/M5YYaZqYmuyi0n2nlI9dMGi9q38ihTPFOpCPpEWNwPJfpteBIyfZcVtyEoWlBAUE5BHYBgtEzLtIjg/J+aW7obpUiSYx/XhnvQI1TOkOPyKE= Authentication-Results: lists.freedesktop.org; dkim=none (message not signed) header.d=none; lists.freedesktop.org; dmarc=none action=none header.from=amd.com; Received: from SN6PR12MB4623.namprd12.prod.outlook.com (2603:10b6:805:e9::17) by SN6PR12MB2702.namprd12.prod.outlook.com (2603:10b6:805:6c::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.20; Tue, 1 Jun 2021 20:17:26 +0000 Received: from SN6PR12MB4623.namprd12.prod.outlook.com ([fe80::ad51:8c49:b171:856c]) by SN6PR12MB4623.namprd12.prod.outlook.com ([fe80::ad51:8c49:b171:856c%7]) with mapi id 15.20.4173.030; Tue, 1 Jun 2021 20:17:26 +0000 From: Andrey Grodzovsky To: dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org Subject: [PATCH 5/7] test/amdgpu/hotunplug: Add basic test Date: Tue, 1 Jun 2021 16:17:00 -0400 Message-Id: <20210601201702.23316-6-andrey.grodzovsky@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210601201702.23316-1-andrey.grodzovsky@amd.com> References: <20210601201702.23316-1-andrey.grodzovsky@amd.com> X-Originating-IP: [2607:fea8:3edf:49b0:5b64:13a3:c94c:964b] X-ClientProxiedBy: YTXPR0101CA0048.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b00:1::25) To SN6PR12MB4623.namprd12.prod.outlook.com (2603:10b6:805:e9::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from agrodzovsky-All-Series.hitronhub.home (2607:fea8:3edf:49b0:5b64:13a3:c94c:964b) by YTXPR0101CA0048.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b00:1::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.24 via Frontend Transport; Tue, 1 Jun 2021 20:17:25 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0217fb5f-b3ad-4273-d873-08d9253a45cf X-MS-TrafficTypeDiagnostic: SN6PR12MB2702: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IxaQgxEAJS0Q1Ugb2FxrZBvNIoXaIIEjUNUsZkzL4v3nxE2XiABUGWrYga6LEMsCnthNjX0m8ieQA/s03XoqnD8EkQ99dvfuSEFUycHH95DneooFW3OS/DHZbC25bbv0BWanPM9unhEQ9kPbfdsissOaIg+EoZcck7T7Cv+MvXQGeiBoDgo/ymIf1WBbADpcJvN1Zxa8H+QInSt2dixML1g/q/ajgSYqIS0gdC3M7YU65vhVMWP01PU/hwqjA/+1dwiE0RjdX9SymmLfaxuKksdGfa+JsYNdoSV3TXytjC4Ggvlv3BdwVY9pXdpEAweLin3orepaxrQtOVcu1TqldV50Ui8e0QRFntZZzF72P8JMvcBWps0/RgqO/fkVsFccBR634KSWb/tE1HH6xZbwpdxzK9tQ52N1kjESZA+mLlNtKpFSqHivgmYCG0FbPsbFbuF3xE89kXjXj0iPcUb2i/LMcuvFISNLmSSWmRGcAYWe2vTiig8jwyz2BIQfuB1COlcnMY6M/cjnQIyar2whS/mzGoXQbOf3IsQN6TexsZYws4FVo9t7d8MRwm6kOt8kQjcpJ0OPn+CwYKsv+i/YkqW3mbx9t0ZmfMfZ8cNH5kk= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR12MB4623.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(366004)(396003)(39860400002)(136003)(346002)(16526019)(6506007)(2616005)(38100700002)(1076003)(6512007)(5660300002)(83380400001)(52116002)(478600001)(186003)(6486002)(316002)(66946007)(8936002)(8676002)(2906002)(66556008)(66476007)(6666004)(86362001)(44832011)(36756003)(4326008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: jdSx6etN+OVro/yga/yQCGsMtm7YbsYP/+SJqilSp386iBhquZ0I00BX5GPdDMmStR+dpncCSZhF2aG961oYUkL/kaLVJ6pmJ5x6TXa0dART615vnSWrrk/IlP5uZ9vQCJQEolZIwW7JZ5mWfEoNIXIb1jj1ze4MTwHa0LfOU0Bv8O6nAE+kKWrHf6WUQVDjZxmjQ4v1ffxvBMzItGeCA79kg6fOuSpvtz5rgtF2fdgCDVQKqO94XgGK5klf6kosuLWgDueBCcf+b3HaJtJDLyXhrDxxclcQJO/a0V+gC1P5YE46bJWhJH2fHGWvcR8xk+DqsY8Z0sE3/WOejGAbY/0UaxvQ0WFk3B32rC3aHMT5SImgkk7+1mvJw3YYdaz7azkzcDyV1IpyrbQPU39Kgx0xCPN1qUSGr5yYe720ez1QTxpuegZTF/oKHBUv+N7JESGwgYXgySSUHHJ2pEqxXjn3nR3Uhrmiv7QhWSQZRaiKMzIbsaoBCvkNydAKCkNraorx5vKef0TAjh2B1mEIJhilywqjCh5H3bm/BKVcSo+ojxSknOrINsMzIPBn72A3VVm5HgtQQN/K/k3WvnT3tBCyDpPagWf0a6k81+juq//78sU5VxxX6REZbXt1Mi8aHE6bHdopgQVtdaiyMUYeM8dlJDv8S3nGH6b0ep/EPWMk0UAf6AMrC8lpQk2yULlATjUC0rVccEhgjURFJmXvuIvmHlVU8W5CdkAfZqzhXddQ/y5PG1gF2iXa+Myq0I+LC4d5Nqd1qPohQrny1KSF4FlmttgGh2Uanpc56vMpYxwDhEMtgpQDKiISlcdrVNvlLDECCZy1/dWUpxvUZEORH/9epuMdTdgebVfgfFbSk+cZh+5nHlPtoNn26YzzBnYLsFFCKWRf08mBLEDIyiHqHplTyf1SoNcZIqQBRr4bldjqjy+NWPO26UM9McsAWrqlqcYcxOHvDlpaOoMxOa2V4Zvr2rDtOk7zxYRP1nt+hY/a4EYpy0V0PUwv8MgykPJFmeg8R9PtuJkcFpWRuxoFH/fp0QqrhzBjZ7h6Ygn2dKn2Tlf0u4ALKwXwhw14hgjTPw89Crsq6OAiv9zQYKCG+V7bZ4unVScg2DBeGL0PsUR/G6O+oFWIS1titWwyu7pD8+NBbbXE0JeHeDL4NGmMikDTHzrHxj+uUmbEyvRi2yVrcqx1pDIZEKB7TDLXyf98BXRYEIv+zJiHk1CIoz0ivIC0MdDUumyzDHE601ZZWE/SkUUKKGZ4UQmwvLorpb+RzU0xhyeafV8KZpL734HQLE8fRdg52lOZAEzfO85/wB2q0pR8TNYrSmBJ1UkEREMwQqnU73MaoIiJmDBAiydW6Gh6wPxxqB9D1BifpZy+pq+KktV6r3Iv8Oi71Jo00++C X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0217fb5f-b3ad-4273-d873-08d9253a45cf X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB4623.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jun 2021 20:17:26.1764 (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: cGjvacX+0uHnB8i2wmZZSOvClPExjuG++O89LatFr8YBYAesCTtURC17yf6+naUVNlDdZFmBYM6iTh0K8vxz+g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB2702 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: Alexander.Deucher@amd.com, ckoenig.leichtzumerken@gmail.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Add plug/unplug device and open/close device file infrastrucutre. Add basic test - unplug device while device file still open. Close device file afterwards and replug the device. Signed-off-by: Andrey Grodzovsky --- tests/amdgpu/hotunplug_tests.c | 135 +++++++++++++++++++++++++-------- 1 file changed, 105 insertions(+), 30 deletions(-) diff --git a/tests/amdgpu/hotunplug_tests.c b/tests/amdgpu/hotunplug_tests.c index 9d11dae4..c2bc1cf2 100644 --- a/tests/amdgpu/hotunplug_tests.c +++ b/tests/amdgpu/hotunplug_tests.c @@ -21,9 +21,11 @@ * */ -#include #include #include +#include +#include +#include #if HAVE_ALLOCA_H # include #endif @@ -33,40 +35,40 @@ #include "amdgpu_test.h" #include "amdgpu_drm.h" #include "amdgpu_internal.h" - +#include "xf86drm.h" #include static amdgpu_device_handle device_handle; static uint32_t major_version; static uint32_t minor_version; - -static uint32_t family_id; -static uint32_t chip_rev; -static uint32_t chip_id; +static char *sysfs_remove = NULL; CU_BOOL suite_hotunplug_tests_enable(void) { CU_BOOL enable = CU_TRUE; + drmDevicePtr device; + + if (drmGetDevice2(drm_amdgpu[0], DRM_DEVICE_GET_PCI_REVISION, &device)) { + printf("\n\nGPU Failed to get DRM device PCI info!\n"); + return CU_FALSE; + } + + if (device->bustype != DRM_BUS_PCI) { + printf("\n\nGPU device is not on PCI bus!\n"); + amdgpu_device_deinitialize(device_handle); + return CU_FALSE; + } + + /* Disable until the hot-unplug support in kernel gets into drm-next */ + if (major_version < 0xff) + enable = false; if (amdgpu_device_initialize(drm_amdgpu[0], &major_version, &minor_version, &device_handle)) return CU_FALSE; - family_id = device_handle->info.family_id; - chip_id = device_handle->info.chip_external_rev; - chip_rev = device_handle->info.chip_rev; - - /* - * Only enable for ASICs supporting GPU reset and for which it's enabled - * by default (currently GFX8/9 dGPUS) - */ - if (family_id != AMDGPU_FAMILY_VI && - family_id != AMDGPU_FAMILY_AI && - family_id != AMDGPU_FAMILY_CI) { - printf("\n\nGPU reset is not enabled for the ASIC, hotunplug suite disabled\n"); - enable = CU_FALSE; - } + /* TODO Once DRM version for unplug feature ready compare here agains it*/ if (amdgpu_device_deinitialize(device_handle)) return CU_FALSE; @@ -75,8 +77,46 @@ CU_BOOL suite_hotunplug_tests_enable(void) } int suite_hotunplug_tests_init(void) +{ + /* We need to open/close device at each test manually */ + amdgpu_close_devices(); + + return CUE_SUCCESS; +} + +int suite_hotunplug_tests_clean(void) +{ + + + return CUE_SUCCESS; +} + +static int amdgpu_hotunplug_trigger(const char *pathname) +{ + int fd, len; + + fd = open(pathname, O_WRONLY); + if (fd < 0) + return -errno; + + len = write(fd, "1", 1); + close(fd); + + return len; +} + +static int amdgpu_hotunplug_setup_test() { int r; + char *tmp_str; + + if (amdgpu_open_device_on_test_index(open_render_node) <= 0) { + printf("\n\n Failed to reopen device file!\n"); + return CUE_SINIT_FAILED; + + + + } r = amdgpu_device_initialize(drm_amdgpu[0], &major_version, &minor_version, &device_handle); @@ -89,27 +129,62 @@ int suite_hotunplug_tests_init(void) return CUE_SINIT_FAILED; } - return CUE_SUCCESS; + tmp_str = drmGetCharDeviceFromFd(drm_amdgpu[0]); + if (!tmp_str){ + printf("\n\n Device path not found!\n"); + return CUE_SINIT_FAILED; + } + + sysfs_remove = realloc(tmp_str, strlen(tmp_str) * 2); + strcat(sysfs_remove, "/device/remove"); + + return 0; + } -int suite_hotunplug_tests_clean(void) +static int amdgpu_hotunplug_teardown_test() { - int r = amdgpu_device_deinitialize(device_handle); - - if (r == 0) - return CUE_SUCCESS; - else + if (amdgpu_device_deinitialize(device_handle)) return CUE_SCLEAN_FAILED; + + amdgpu_close_devices(); + + if (sysfs_remove) + free(sysfs_remove); + + return 0; +} + +static inline int amdgpu_hotunplug_remove() +{ + return amdgpu_hotunplug_trigger(sysfs_remove); +} + +static inline int amdgpu_hotunplug_rescan() +{ + return amdgpu_hotunplug_trigger("/sys/bus/pci/rescan"); } -static void amdgpu_hotunplug_gfx(void) +static void amdgpu_hotunplug_simple(void) { - printf("Hello!\n"); + int r; + + r = amdgpu_hotunplug_setup_test(); + CU_ASSERT_EQUAL(r , 0); + + r = amdgpu_hotunplug_remove(); + CU_ASSERT_EQUAL(r > 0, 1); + + r = amdgpu_hotunplug_teardown_test(); + CU_ASSERT_EQUAL(r , 0); + + r = amdgpu_hotunplug_rescan(); + CU_ASSERT_EQUAL(r > 0, 1); } CU_TestInfo hotunplug_tests[] = { - { "gfx ring block test (set amdgpu.lockup_timeout=50)", amdgpu_hotunplug_gfx }, + { "Unplug card and rescan the bus to plug it back", amdgpu_hotunplug_simple }, CU_TEST_INFO_NULL, }; From patchwork Tue Jun 1 20:17:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Grodzovsky X-Patchwork-Id: 12292203 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,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 835EEC4708F for ; Tue, 1 Jun 2021 20:17:40 +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 4A2D7613DB for ; Tue, 1 Jun 2021 20:17:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4A2D7613DB Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8BF566EB0A; Tue, 1 Jun 2021 20:17:30 +0000 (UTC) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2077.outbound.protection.outlook.com [40.107.94.77]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4ACBB6EAE2; Tue, 1 Jun 2021 20:17:29 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b/mhUKj4lU0XuHCzaDuJjLV9CATvXjckcmgN9DxAmfs0VhSPAoGmJV4SETFxkNDPHKzL4XX0sds/Pp1mi5lQMlMF5fn6ZDEzNERu0LGrKgnKoDgxHUGUyjgQ7bZb4lxl9ZIM+xOnWnkIXGEsjroHN0fbN/wDwEDobIoEq61oy5ex5U+p2niQMfnYrvzs6GL/t1aUM6/9FE0z68xJ2ogppQFac+XixrvsijTPeQreHMYjWWJdrIZZydYuEjAqwIMZkTORKv6hRM/cditB7sV2rl8z/z8MkxBMyo562V4XoRldkdNEz9/toJoLTDD77ojC0KhT6LIMeGNa07RdAu+9rQ== 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=3KuXxkA7rHvayWhCGh3oLlIwj1eONOIedrRNrO4Wuyk=; b=GwEm3d5ClUAlcGEy9zbigYXjhJKbhvJgHQQ8jexCsT2Ja7RVxYwzJE6DpHj7tBo/ev6uoN3XQIpuB5lgK6msOcYCEM0AtBQDKs+BjcZQ33kBSpm2jL6RkK6ll1qUbSrllOSbT3sqbMo5B07TGzSHc1rGN9MKRYN6UAY2/OIg65BDp5HogZX3bH6wTeR8Q0GSskNTA+vBsOt+30iPmyQyq5l8Y5j8UevCdnJbBlMUxkc1p9b8gtJceM/CPrs9tZDxYlYT+AxYJu9uqG3qltnVB7aFp+z0qHoEyqKBeXjIVZMtVivYAoWFV2eW+PIgMoh2Mtt7vFBaX7iE7ImsojWniQ== 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=3KuXxkA7rHvayWhCGh3oLlIwj1eONOIedrRNrO4Wuyk=; b=XKLGgr3HHgyfjVx1ed2tuhakgjl3q5oZFPj59jy0Ckv5Bg/jFQLp0ppFS/0jTBZA+Szcl1CbVPEYajQDV6fetko/3g1sMZXfXqAuZeGUQxUXvrLbaDuX+ECKsi1yeq7kVzlcw2PAO8OMqT+IbzWTnX6ZhpNs367R5GibUZFdBoU= Authentication-Results: lists.freedesktop.org; dkim=none (message not signed) header.d=none; lists.freedesktop.org; dmarc=none action=none header.from=amd.com; Received: from SN6PR12MB4623.namprd12.prod.outlook.com (2603:10b6:805:e9::17) by SN6PR12MB2702.namprd12.prod.outlook.com (2603:10b6:805:6c::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.20; Tue, 1 Jun 2021 20:17:27 +0000 Received: from SN6PR12MB4623.namprd12.prod.outlook.com ([fe80::ad51:8c49:b171:856c]) by SN6PR12MB4623.namprd12.prod.outlook.com ([fe80::ad51:8c49:b171:856c%7]) with mapi id 15.20.4173.030; Tue, 1 Jun 2021 20:17:27 +0000 From: Andrey Grodzovsky To: dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org Subject: [PATCH 6/7] tests/amdgpu/hotunplug: Add unplug with cs test. Date: Tue, 1 Jun 2021 16:17:01 -0400 Message-Id: <20210601201702.23316-7-andrey.grodzovsky@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210601201702.23316-1-andrey.grodzovsky@amd.com> References: <20210601201702.23316-1-andrey.grodzovsky@amd.com> X-Originating-IP: [2607:fea8:3edf:49b0:5b64:13a3:c94c:964b] X-ClientProxiedBy: YTXPR0101CA0048.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b00:1::25) To SN6PR12MB4623.namprd12.prod.outlook.com (2603:10b6:805:e9::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from agrodzovsky-All-Series.hitronhub.home (2607:fea8:3edf:49b0:5b64:13a3:c94c:964b) by YTXPR0101CA0048.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b00:1::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.24 via Frontend Transport; Tue, 1 Jun 2021 20:17:26 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 18f3b099-ec71-4aba-2d83-08d9253a46a7 X-MS-TrafficTypeDiagnostic: SN6PR12MB2702: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vDlEACAIguesX3U5nt5lsB1ROshorPFsRlPWIyK07mTcLT5tNTRHLNbm5rFafpaakjOpZkTyEapPFfw+AklTbIKOjHCkRCKomYQNDi6jgIwS+xN05GNiKR3sOW0Mu/9ygQtOPEG5QEI2nZkP8Tm5NhziN4YXvoL75aEf4hrf4Y/EGBtaFXSkT6EcI4Mm02w4/2LGPcX0abt9SC8GkUM79uKehaiHg8BKZ7Y/iJwdz2/MKC53rmvrf8gUMhwt16kLY9SQOD9+6KNC1eoZEd4rcVXpYBElJKKRaarfxDwZcqTP1AvZqeiQk+5ki7Y6UPdKzTPuhYH8mYwxo7fS3SjB70X0H+fmAHPx35xzKWGFURshl8sxKdaXAc8l0AmxmJiD439tTw9APRDlDAhTqgmMOYM91JJ/bibyzv/dUXPXrEDS71zRAPrduu40FIO1ayMKCUyukAzYr57nlkqi8wxEE5LM3iJ1gvisFqYF7s4p4A6h3jusBJYih8SWKP2dF9mhumgWz07LM4TENjlkVtLY1GKDxyqWVsS31YFnuqfqKYJK/pT9Jl0I2a6URUZ2ENGCvLZ/uSGRpXe/zS16JdhsPOe5J2czwYx/EjlneNLZR6I= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR12MB4623.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(366004)(396003)(39860400002)(136003)(346002)(16526019)(6506007)(2616005)(38100700002)(1076003)(6512007)(5660300002)(83380400001)(52116002)(478600001)(186003)(6486002)(316002)(66946007)(8936002)(8676002)(2906002)(66556008)(66476007)(6666004)(86362001)(44832011)(36756003)(4326008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: POsXb/xygh8wenVYOFTMn3/N5nsgOrGveWTCN3T+ZKuEr5ITg45oqG5GrQteLEF/ELoNUxwFpt/wg5lgOUntfzq/IMb3vTG6UcVhputo04cvR+8HnLreIXLk0ZzSIyRqGiW5FhRpWFDYpf5E4UTIZv2ttHStj9LPb7e3dQVt0SQeQ1GwSd6EdE8tscHW0ca2ipXNte9XigsZvh4710wIu8JG7Tu7T3xd9GuljxC8LnXP+iZIavuozFsiGuk5eG92kxeIM8r8Oux0bTi9luOOjAosceciiKuCz6ZQlzbxnN6fDdqOE7quT+s0HhrnXR8Hpg5PxGbeqhjrtQ4RyWenIt3iJCEMAtEwxZS0KCLsPVeBsr0L54RJ/kX652ScgCNTKqWYHEBFmR/8st+j/uDQm5ISlcxOg62dPQGDb/3UrgEGQ/dTk6SKPTzIY1ogQ6+hUxCr4cB7ATPKAEVVeGBkV+NNCjN9TQU0VKQPwhub9mx/Ciybx5WNroSbH5upYvz353kLy4mDaGXo4dYvvK+MUTobY2YRLe/Tpc7Gi/4M4LO3+lZ2jBc+KWKDZ4Jlr/umsvDEf2iwRGScyrW45TyM2zUO3Voy+WxhJjnXBpe+vnYs7U+Jxu9JWVxLBx77QTXCWQmCYuR5PxOBBgf2IjuVG5473bBw1NHxKY9rnSfvFEv+0VXRHC7+6N4zWeGa8iULTXJvobUzZN1mVPEENAQ9NiF15+FT7ObQ3XfWHCPMHy/rL56I6+ptUgtTsWTjPUQUxquLCircYNLyvO+nqVNrvt8qNCB4w17ad5rk6kecYoxfqP5OLuMK0VcaRaQjrrAukker66DtlnOwGvbVxP35TI+zvVB5ESBoyOdA2yKqFstsshAgUs8s7aOkaeThZbln/w9/7TYDWvc8hhHBw9XwPFWiCawXceli728M9INr/U6RzzSiDMsrKTENZ2JAlwbhzsP3mpgG3J4TCmdY64L/0KyjhhSLG7wEhY6lmTbCoOu75ZarrkjCU9FEx/DIfhp45NEki21C0Hx26J9TP/zp2ht+h7n96OZuNUwPGQ//F9LHigXDAUv7MCxfCaP1CCoC3tzXNHNmGT26eZsa/jZaNVlQQwG14NnhsYRC0EahFc5ZxTasMsu5CPKLxevvtYFYGHCrvFgPIe9Fm28t+kwEOspdnR6njzMWns0+26iFmxqBDHnVUDmQJQ8ZJ2mAoJ9SnTTMREQbL6Ef3CFxxLhc10jRZ2c3AIubMfiqfDrvVh795ML+fYNZkbv19f+N0OO6Bu/vNb5VYtld09MC9SuLcoPGwyiX08FyjOPKtS+rf7evEAxtASS3gQCigL8DYg4NVditCn99J4H3P5c67rMCadgOo/Sh2n6CNG78iFTVaFUXOjH3KF3HrXjmRChScbUY X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 18f3b099-ec71-4aba-2d83-08d9253a46a7 X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB4623.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jun 2021 20:17:27.5886 (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: P0QXRSzD4qSNoozXccfaiP5/R6AOR3HTXciBvpRnB4l+jrlYi0OMUvKO/WS96zdvy7gwW7iUV+TO6wjbO/bRPw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB2702 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: Alexander.Deucher@amd.com, ckoenig.leichtzumerken@gmail.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Same as simple test but while doing cs Signed-off-by: Andrey Grodzovsky --- tests/amdgpu/hotunplug_tests.c | 128 ++++++++++++++++++++++++++++++++- 1 file changed, 126 insertions(+), 2 deletions(-) diff --git a/tests/amdgpu/hotunplug_tests.c b/tests/amdgpu/hotunplug_tests.c index c2bc1cf2..6e133a07 100644 --- a/tests/amdgpu/hotunplug_tests.c +++ b/tests/amdgpu/hotunplug_tests.c @@ -38,11 +38,13 @@ #include "xf86drm.h" #include +#define GFX_COMPUTE_NOP 0xffff1000 static amdgpu_device_handle device_handle; static uint32_t major_version; static uint32_t minor_version; static char *sysfs_remove = NULL; +static bool do_cs; CU_BOOL suite_hotunplug_tests_enable(void) { @@ -110,7 +112,7 @@ static int amdgpu_hotunplug_setup_test() int r; char *tmp_str; - if (amdgpu_open_device_on_test_index(open_render_node) <= 0) { + if (amdgpu_open_device_on_test_index(open_render_node) < 0) { printf("\n\n Failed to reopen device file!\n"); return CUE_SINIT_FAILED; @@ -165,17 +167,128 @@ static inline int amdgpu_hotunplug_rescan() return amdgpu_hotunplug_trigger("/sys/bus/pci/rescan"); } +static int amdgpu_cs_sync(amdgpu_context_handle context, + unsigned int ip_type, + int ring, + unsigned int seqno) +{ + struct amdgpu_cs_fence fence = { + .context = context, + .ip_type = ip_type, + .ring = ring, + .fence = seqno, + }; + uint32_t expired; + + return amdgpu_cs_query_fence_status(&fence, + AMDGPU_TIMEOUT_INFINITE, + 0, &expired); +} -static void amdgpu_hotunplug_simple(void) +static void *amdgpu_nop_cs() +{ + amdgpu_bo_handle ib_result_handle; + void *ib_result_cpu; + uint64_t ib_result_mc_address; + uint32_t *ptr; + int i, r; + amdgpu_bo_list_handle bo_list; + amdgpu_va_handle va_handle; + amdgpu_context_handle context; + struct amdgpu_cs_request ibs_request; + struct amdgpu_cs_ib_info ib_info; + + r = amdgpu_cs_ctx_create(device_handle, &context); + CU_ASSERT_EQUAL(r, 0); + + r = amdgpu_bo_alloc_and_map(device_handle, 4096, 4096, + AMDGPU_GEM_DOMAIN_GTT, 0, + &ib_result_handle, &ib_result_cpu, + &ib_result_mc_address, &va_handle); + CU_ASSERT_EQUAL(r, 0); + + ptr = ib_result_cpu; + for (i = 0; i < 16; ++i) + ptr[i] = GFX_COMPUTE_NOP; + + r = amdgpu_bo_list_create(device_handle, 1, &ib_result_handle, NULL, &bo_list); + CU_ASSERT_EQUAL(r, 0); + + memset(&ib_info, 0, sizeof(struct amdgpu_cs_ib_info)); + ib_info.ib_mc_address = ib_result_mc_address; + ib_info.size = 16; + + memset(&ibs_request, 0, sizeof(struct amdgpu_cs_request)); + ibs_request.ip_type = AMDGPU_HW_IP_GFX; + ibs_request.ring = 0; + ibs_request.number_of_ibs = 1; + ibs_request.ibs = &ib_info; + ibs_request.resources = bo_list; + + while (do_cs) + amdgpu_cs_submit(context, 0, &ibs_request, 1); + + r = amdgpu_cs_sync(context, AMDGPU_HW_IP_GFX, 0, ibs_request.seq_no); + CU_ASSERT_EQUAL((r == 0 || r == -ECANCELED), 1); + + amdgpu_bo_list_destroy(bo_list); + amdgpu_bo_unmap_and_free(ib_result_handle, va_handle, + ib_result_mc_address, 4096); + + amdgpu_cs_ctx_free(context); + + return (void *)0; +} + +static pthread_t* amdgpu_create_cs_thread() +{ + int r; + pthread_t *thread = malloc(sizeof(*thread)); + if (!thread) + return NULL; + + do_cs = true; + + r = pthread_create(thread, NULL, amdgpu_nop_cs, NULL); + CU_ASSERT_EQUAL(r, 0); + + /* Give thread enough time to start*/ + usleep(100000); + return thread; +} + +static void amdgpu_destroy_cs_thread(pthread_t *thread) +{ + void *status; + + do_cs = false; + + pthread_join(*thread, &status); + CU_ASSERT_EQUAL(status, 0); + + free(thread); +} + + +static void amdgpu_hotunplug_test(bool with_cs) { int r; + pthread_t *thread = NULL; r = amdgpu_hotunplug_setup_test(); CU_ASSERT_EQUAL(r , 0); + if (with_cs) { + thread = amdgpu_create_cs_thread(); + CU_ASSERT_NOT_EQUAL(thread, NULL); + } + r = amdgpu_hotunplug_remove(); CU_ASSERT_EQUAL(r > 0, 1); + if (with_cs) + amdgpu_destroy_cs_thread(thread); + r = amdgpu_hotunplug_teardown_test(); CU_ASSERT_EQUAL(r , 0); @@ -183,8 +296,19 @@ static void amdgpu_hotunplug_simple(void) CU_ASSERT_EQUAL(r > 0, 1); } +static void amdgpu_hotunplug_simple(void) +{ + amdgpu_hotunplug_test(false); +} + +static void amdgpu_hotunplug_with_cs(void) +{ + amdgpu_hotunplug_test(true); +} + CU_TestInfo hotunplug_tests[] = { { "Unplug card and rescan the bus to plug it back", amdgpu_hotunplug_simple }, + { "Same as first test but with command submission", amdgpu_hotunplug_with_cs }, CU_TEST_INFO_NULL, }; From patchwork Tue Jun 1 20:17:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Grodzovsky X-Patchwork-Id: 12292205 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,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 1A311C47080 for ; Tue, 1 Jun 2021 20:17:42 +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 DBE53613D6 for ; Tue, 1 Jun 2021 20:17:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DBE53613D6 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D95C36EB10; Tue, 1 Jun 2021 20:17:31 +0000 (UTC) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2078.outbound.protection.outlook.com [40.107.94.78]) by gabe.freedesktop.org (Postfix) with ESMTPS id 743796EB0C; Tue, 1 Jun 2021 20:17:30 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CMRf9ogja/lJODhHAIM4xeuFd23qInC1RmOMtw0G63qVf8B0Luh+PAHHCiaqA5WPg8rbxSRVERa2hj/C4LmwbaJwae3CRIQNQ1TsezWnAt2JcVkr/KgB5W3yQbyRxbcMeXnDYQUszDyw6bYK0bP1YQqqXfyrxi9zx/Pf2QRWOLqRaBy38t3t1guMc3Q9f+tM2HuWnU8YEm7bO9WRwWFTPp2ELJOyotM8UlJ2LSOAwv2Et3LS8QvKlm4iP/LdNP7uxgVZtG6+tewdjWwCA+zgq7RTD619Neu4cc6PwxgqP66pui4SPQpnFWNf7+vXvfVWLU60GwGJSwUKpVxDADTJDQ== 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=M1uQUDa+D9HISb73PbP87cu0bwgx6Mc5NImfIpUN6qA=; b=dmJtJ/Nu6FsjJt0bW5go87ilK3Q5lzSq9e/OPdoZB6yvKfoycmowRNUy1Dydl+D5MmjDKpxmdLiLRsc/iksTC68I4eh6Mwr/LMEVpwEhEC5WLAco9NzeTxseRkoOdFTzLltQ1k2ZcXoYtFzhsQBYPumWPoqOw8O/xaARlWuJw7ZBP1t+A61oNt6kde3d2m9NuhPR4/NstoTGNHb7yo04FatHz1gAy1BOAV/pe1xzaHLSBN2n00pjAIvDoxKFTPEBJ4hJ0daw0rYg8bbF2LddVSoTNYSVdeU5Wzj6cj/JumB2F7ZSEpg+Au1K+eU76YWWD5KncRNbA6iwf7yTk7DNsw== 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=M1uQUDa+D9HISb73PbP87cu0bwgx6Mc5NImfIpUN6qA=; b=a6dhbvdZJcf/1j4CenwZ8m/kQB8PY0PHJB4r3KmcrF0az5fQFCC476dSZvhygTmJcO4NL47SncDVkfVGVrtkeST5nzPXQpKGv3LEH2YYdADmkSp27VFE8kLlXh/QKssRjSHmxIEzXNW7UxYd8ws1oD700L4Eu/euPATimL2I1pA= Authentication-Results: lists.freedesktop.org; dkim=none (message not signed) header.d=none; lists.freedesktop.org; dmarc=none action=none header.from=amd.com; Received: from SN6PR12MB4623.namprd12.prod.outlook.com (2603:10b6:805:e9::17) by SN6PR12MB2702.namprd12.prod.outlook.com (2603:10b6:805:6c::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.20; Tue, 1 Jun 2021 20:17:29 +0000 Received: from SN6PR12MB4623.namprd12.prod.outlook.com ([fe80::ad51:8c49:b171:856c]) by SN6PR12MB4623.namprd12.prod.outlook.com ([fe80::ad51:8c49:b171:856c%7]) with mapi id 15.20.4173.030; Tue, 1 Jun 2021 20:17:29 +0000 From: Andrey Grodzovsky To: dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org Subject: [PATCH 7/7] tests/amdgpu/hotunplug: Add hotunplug with exported bo test Date: Tue, 1 Jun 2021 16:17:02 -0400 Message-Id: <20210601201702.23316-8-andrey.grodzovsky@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210601201702.23316-1-andrey.grodzovsky@amd.com> References: <20210601201702.23316-1-andrey.grodzovsky@amd.com> X-Originating-IP: [2607:fea8:3edf:49b0:5b64:13a3:c94c:964b] X-ClientProxiedBy: YTXPR0101CA0048.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b00:1::25) To SN6PR12MB4623.namprd12.prod.outlook.com (2603:10b6:805:e9::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from agrodzovsky-All-Series.hitronhub.home (2607:fea8:3edf:49b0:5b64:13a3:c94c:964b) by YTXPR0101CA0048.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b00:1::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.24 via Frontend Transport; Tue, 1 Jun 2021 20:17:28 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: aee54789-4be9-4cb8-3ed5-08d9253a47a5 X-MS-TrafficTypeDiagnostic: SN6PR12MB2702: 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: MQgBTnE+ZOQKtHvEzaw0TKBM3QZWt5LzcL1tHYVnSZQNXmIjA1N6WkC2MGuvMB2H1XtHAm8+CkF9xWQ88rvcrQbJFrX8HTHzxukWVxNPLLbbOPHSUM7B24Kf90EEMw/bVcIWFFtmn3h0wdi2W146Dai8AJag9SLVnXEX6EmP3hkmFlhPknwbUAjM9hgr9wWin+c0wCggaWVeft6Vva1scmE8oZgjtpUqY6vDpIeFUEhvNJ1GWkfMLjnhlvXK0I6VWakbkHeNgjAy0DSsm0TYT0wNce1ZqlQRSPQ6vNzTaHb0cjC2fMwhsY8UUFk48EVpmuSZASb2vWKKxLxsXok5wVJWFm1S8hpv4U6thsKnTcxtNCrsQj/qv/Jx6Tl8blZDG06ATnAB8sS/Un+xReRyVRyU5xqEXLxanj036nFQuk2v4/Z3JKh8OAp7E1lNJiUpCHFCT5Vu1l/NXWf/ly/VrW2WMVvqu3i99RnxLApscHRRar4rNbJ421wNNfoK/RmmXaNC3sFBzLkXPgpBV3vQyovhn9d1CSMYNbWTkQyeIHXL6A+sOiJt6iWfzdKgfVezQauZWapHdXWQghnt1RL+ml72GTkYJD96hUXVqIqbICI= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR12MB4623.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(366004)(396003)(39860400002)(136003)(346002)(16526019)(6506007)(2616005)(38100700002)(1076003)(6512007)(5660300002)(83380400001)(52116002)(478600001)(186003)(6486002)(316002)(66946007)(8936002)(8676002)(2906002)(66556008)(66476007)(6666004)(86362001)(44832011)(36756003)(4326008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: CilxtRXf8rCeiDkY3CTno+Ph0vmI63iBKoLxYLZoVpNCS4OsfwJem1hGrkM6KHYVDNQAWN8ST2uMIYgIsuTxRSWWB1I8ywDMISQUTNZl9T8yQ6OdFFYaGQWTfWAy8pV6zZ0+rTLgmx5kgtczwr5ex5XowDYVah72Cr5XvsgCOMlBZ2yHEXCtDGHZovNPmEGCJWc2fxgeHs3IDNCHbKp4znXqDxiYQ8QWdqHsAxB9ajbqL85MvWiltdDXmWEtIJWJDm9r7z5gqZQH7XKuaOjbP3AGod2/zsE1CSZaKejuMx2w+mNw3ffOCnwWVuLAWXRkb9wFi+QzWvBgudUu479A0/kkJSYPgsjN8aol2500Si319ya8MIelqSbDFGjiXtfh3eSqfdVyyEernEy4oZlu0yq3m1rbuySOxzO8agJKCaQMG1jUWQhQgP6I6IwkAftmZNjhoF+ak8sXgMXATi90eRcpb5jgx5u9i9R+E3TX0S6qUASAtqV5WZDMcXaZYVnknKX3oZ3xUA72O05IwBKdnrGjuijHz/XH75gdJqnXO3Sc6sEIelwHMHBHGoquuQkAJuOeU3x/GJnylL8HkMvLje0MvvrzlnewQVkZPf+zsF0jy+Zfgt4KowpcjC+0d8Kda/4hWWTTYVQGoR26js9fp27cH3wIOPnPdkQOCVvReyYxQjZ4t5eaIDGMduYuoSRoJ2pMj1iWbZnCsnQc4MRrz0WXn/4iD21TcBVa6uNEsKKw4PZSLXtfA+A93TwsA6DaQdks0zeBBDpzfOe6mIsPmwXAVwT7Yx3ejA0MTq4xabJKY3fv5yzlAbxiCikpd2jhd5KZeFyn8uFy6MtNSirQzLaWWtkN1af5SlUfkaM+rcWcdSEjAj1AYM3uEKfe+FXvQ78rO9yveLUMye8kKWxqRQsSOcNMDTE8w6u9sUutdXojZTSPJbuT12Zv0R/yb6n1bqfsdLbljZ2k+1iaeHIYUPAhUv2rvDyKnRuWn0epKHTHEUziaJw55zeQ0xbPJy7llaySZ/iGaN6Siybqo5F0qV3qHxnxACfaOm8g2lHez9wOpaA+Kk6fy3UyKaExDEt71LGZ2p04w9RsgeJiRLNx1PFIaawT0fBkvTaVPvjOFArq77cu5o5e4qKDCiqONflgyaTmH2MzgmB4Rb7IBCDYl8dTAQAKOr9F9K6E9MYsLWI3ovWI0M0fEt7v/FR23kTATPE1ovbrnRVrWralXuxmChRbhYHv9k+9DjNyRwgQZOGJ29v1s8n1fMiyGnds4c37CrJvb32GbCZDwXvNcYqNINXuH2VFzAQcn+qv0RQRBRg3iGJbJJcFUizv4tWN+YtwLhrkvKIcGYxmixKiWrQ0Nf/ygNg+QpkcVjWwWxelfIzMBvMJgJ/i2WggfitX0vQm X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: aee54789-4be9-4cb8-3ed5-08d9253a47a5 X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB4623.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jun 2021 20:17:29.1497 (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: ivg46NFGQSuYp0GRCau/wzz4k/2ObOwiE5SKYLCnqNMkhSwQyc32RJB09rwWuU1GhQpNiT4dPnCdzXQ9DsD+xw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB2702 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: Alexander.Deucher@amd.com, ckoenig.leichtzumerken@gmail.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Disconnect device while BO is exported. Signed-off-by: Andrey Grodzovsky --- tests/amdgpu/hotunplug_tests.c | 46 ++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/tests/amdgpu/hotunplug_tests.c b/tests/amdgpu/hotunplug_tests.c index 6e133a07..01ac6c62 100644 --- a/tests/amdgpu/hotunplug_tests.c +++ b/tests/amdgpu/hotunplug_tests.c @@ -306,10 +306,52 @@ static void amdgpu_hotunplug_with_cs(void) amdgpu_hotunplug_test(true); } +static void amdgpu_hotunplug_with_exported_bo(void) +{ + int r; + uint32_t dma_buf_fd; + unsigned int *ptr; + amdgpu_bo_handle bo_handle; + + struct amdgpu_bo_alloc_request request = { + .alloc_size = 4096, + .phys_alignment = 4096, + .preferred_heap = AMDGPU_GEM_DOMAIN_GTT, + .flags = 0, + }; + + r = amdgpu_hotunplug_setup_test(); + CU_ASSERT_EQUAL(r , 0); + + amdgpu_bo_alloc(device_handle, &request, &bo_handle); + CU_ASSERT_EQUAL(r, 0); + + r = amdgpu_bo_export(bo_handle, amdgpu_bo_handle_type_dma_buf_fd, &dma_buf_fd); + CU_ASSERT_EQUAL(r, 0); + + ptr = mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_SHARED, dma_buf_fd, 0); + CU_ASSERT_NOT_EQUAL(ptr, MAP_FAILED); + + r = amdgpu_hotunplug_remove(); + CU_ASSERT_EQUAL(r > 0, 1); + + amdgpu_bo_free(bo_handle); + + r = amdgpu_hotunplug_teardown_test(); + CU_ASSERT_EQUAL(r , 0); + + *ptr = 0xdeafbeef; + + munmap(ptr, 4096); + close (dma_buf_fd); + + r = amdgpu_hotunplug_rescan(); + CU_ASSERT_EQUAL(r > 0, 1); +} + CU_TestInfo hotunplug_tests[] = { { "Unplug card and rescan the bus to plug it back", amdgpu_hotunplug_simple }, { "Same as first test but with command submission", amdgpu_hotunplug_with_cs }, + { "Unplug with exported bo", amdgpu_hotunplug_with_exported_bo }, CU_TEST_INFO_NULL, }; - -