From patchwork Tue Aug 31 10:35:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liu, Monk" X-Patchwork-Id: 12466895 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,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 1CC28C432BE for ; Tue, 31 Aug 2021 10:35:51 +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 C277960F42 for ; Tue, 31 Aug 2021 10:35:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org C277960F42 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3A7D689AA7; Tue, 31 Aug 2021 10:35:49 +0000 (UTC) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2046.outbound.protection.outlook.com [40.107.223.46]) by gabe.freedesktop.org (Postfix) with ESMTPS id EFF528959D; Tue, 31 Aug 2021 10:35:47 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WjgS33G/ivS6F2ZiXS9akAU0RD1wo9z2PybQ9BvvP8Vlv5TYeJA7y2Y13geFcLeJKqefZadG/qEFZngJ7auO9s6UzJFDpLVyJ/6uOFCeqZWj1Eq+/W04aYfFv87iMmGEhV7YSXpTLKVT5IPHLWJrNNrJ+ZZxSkxUx5YeD/RXBhYlX4acLmd68+6cegRMf7RGM7TwXmEcXIgWJi74emMD+nl4/4Zcbl8Cp2X1vMQe6J2RQ2mxENMAiq41mAk8F3h2bZ/5WAFWO0jYXdt3fwirG7KqJGH5l/4aQGX0tNbuH3pCirVKYWDSQb59YNODM/wI4mVOWOY4iC/uwW/YM4nHRQ== 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=c0nnQlA/+ptCDfrM4bLC6AXTZ2zZdzCPLYr3Gs3LTeQ=; b=NRCPA50xO/1MMBiiBoo5Z+qyN0D/8O46LaDNffDyQjjNB2s7n7jcyUU4piNjulMXgFmevf3w2EAgqkPjA789oHbnqSu1mw+gaY0aMGOzFwgS9jS7QIpHAMY+NGXbIW/0imoOyp29eQtxiTwHP8lZPlc9AMxhgblLwicfUThsq46nRt13jSf4ezkrX2pZdrJE3xnPOJuGyNyCH4tZuWhW73eYQkRIIzkSy40BKSnK1ujPt4cZMFm9BAEC6ewBIfLeoTHbUauz5k6jsKeALPXaO4HUI7eVIWPwHn9xkeDRlBrprfnVWx8Ef+qhhF+7Gs98CaJYinYsFWK7mBDNjPTq4w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=c0nnQlA/+ptCDfrM4bLC6AXTZ2zZdzCPLYr3Gs3LTeQ=; b=wZE71mvA/b2E7+rjZ7x6+OTkefITSl27srSA64lZFSqiLLq7d2ryHPxSZWc0+IY/rcU9LbcFFltDNnEGFHikfsR03Vq/51HV4+EmKbUrQQYYs7IoXub5IHfceAndHznGtPU2XabY/A3sywQyLKm8I0253VLwz/gyN1qlRVOjKMU= Received: from MW4PR03CA0320.namprd03.prod.outlook.com (2603:10b6:303:dd::25) by DM8PR12MB5479.namprd12.prod.outlook.com (2603:10b6:8:38::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.24; Tue, 31 Aug 2021 10:35:45 +0000 Received: from CO1NAM11FT034.eop-nam11.prod.protection.outlook.com (2603:10b6:303:dd:cafe::a9) by MW4PR03CA0320.outlook.office365.com (2603:10b6:303:dd::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.17 via Frontend Transport; Tue, 31 Aug 2021 10:35:45 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; lists.freedesktop.org; dkim=none (message not signed) header.d=none;lists.freedesktop.org; dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; Received: from SATLEXMB03.amd.com (165.204.84.17) by CO1NAM11FT034.mail.protection.outlook.com (10.13.174.248) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4457.17 via Frontend Transport; Tue, 31 Aug 2021 10:35:44 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12; Tue, 31 Aug 2021 05:35:43 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12; Tue, 31 Aug 2021 05:35:43 -0500 Received: from monk-build.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2242.12 via Frontend Transport; Tue, 31 Aug 2021 05:35:42 -0500 From: Monk Liu To: CC: , Monk Liu Subject: [PATCH 1/2] drm/sched: fix the bug of time out calculation(v3) Date: Tue, 31 Aug 2021 18:35:38 +0800 Message-ID: <1630406139-19621-1-git-send-email-Monk.Liu@amd.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 358d1620-766e-460f-85cd-08d96c6b16c2 X-MS-TrafficTypeDiagnostic: DM8PR12MB5479: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:785; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mAFKZ5bDNJ3AEt+ZZ1WFiWfnkx90Oxsz1vpmML24lKxUyiNINFU/270qDUb8CLi8nFdjBYO9emwiIgswJx5T2ojU94J9C31SZm9rdpAt/7dCPU3LNvWPSqoYDAWhHxQWtT57xKuFdV3m0icBIVG993m80sQ6zIbZ589dgEfj9fV+P1BT8jK9JrzvYMhVK275UysTibWamX8ffCqCPnbA0MpGOrXyN3sg5FLjgb8CZpj2zXRIKQUR55tv2p3+s1YoZEfSXovTOxfTWIxF/0ClELYHGfg+qZii6x4a6+HfgHr59d/Guu6UpKOgLZQLXvy5jnKyqboptb9N2bM7s7TaxpJGLkPNwuCRjTDVlehdCsvgGYBB6gtbkUXU5IZtheLFvcTV4K61Wx0PPO/udjsVv75my1oBhGxz3SysoRYbdkGkw2k1jsXs/j+4u6vItfQlNEiFZqh5HJfXNlGnb/QiJ8fRQOP9LSu0WcUTWREP0MYqPlcjPOFiIYfPukUeu8iG9HKbaVNlmQdD4QqkuEmsvssvTebCM+rssmUiSSqPTnWcvheWUkEmfSdy6pP1yYnGsQ8b7NWB/ckoJjUPHWb7Xxh1icaoJvmmDl9FM/Np+3A2N/YOHI6Sk35Y/hiFvfmqduxZVGfocdGr5jLt0X6pz+Kel6R/rOsngo3enmyb0fIX/66CndJKw81Q+Dl1DIOaDr+WOX127ub/SBV6gaOdluNZWHGtUnmmG4pCx/aHd1M= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB03.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(4636009)(346002)(376002)(396003)(39860400002)(136003)(36840700001)(46966006)(4326008)(450100002)(86362001)(82740400003)(316002)(8676002)(2616005)(54906003)(186003)(478600001)(36860700001)(47076005)(70586007)(82310400003)(6666004)(5660300002)(26005)(7696005)(70206006)(36756003)(83380400001)(336012)(426003)(6916009)(356005)(81166007)(8936002)(2906002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2021 10:35:44.7164 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 358d1620-766e-460f-85cd-08d96c6b16c2 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT034.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM8PR12MB5479 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" issue: in cleanup_job the cancle_delayed_work will cancel a TO timer even the its corresponding job is still running. fix: do not cancel the timer in cleanup_job, instead do the cancelling only when the heading job is signaled, and if there is a "next" job we start_timeout again. v2: further cleanup the logic, and do the TDR timer cancelling if the signaled job is the last one in its scheduler. v3: change the issue description remove the cancel_delayed_work in the begining of the cleanup_job recover the implement of drm_sched_job_begin. TODO: 1)introduce pause/resume scheduler in job_timeout to serial the handling of scheduler and job_timeout. 2)drop the bad job's del and insert in scheduler due to above serialization (no race issue anymore with the serialization) tested-by: jingwen Signed-off-by: Monk Liu tested-by: jingwen Signed-off-by: Monk Liu --- drivers/gpu/drm/scheduler/sched_main.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c index a2a9536..ecf8140 100644 --- a/drivers/gpu/drm/scheduler/sched_main.c +++ b/drivers/gpu/drm/scheduler/sched_main.c @@ -676,13 +676,7 @@ drm_sched_get_cleanup_job(struct drm_gpu_scheduler *sched) { struct drm_sched_job *job, *next; - /* - * Don't destroy jobs while the timeout worker is running OR thread - * is being parked and hence assumed to not touch pending_list - */ - if ((sched->timeout != MAX_SCHEDULE_TIMEOUT && - !cancel_delayed_work(&sched->work_tdr)) || - kthread_should_park()) + if (kthread_should_park()) return NULL; spin_lock(&sched->job_list_lock); @@ -693,17 +687,21 @@ drm_sched_get_cleanup_job(struct drm_gpu_scheduler *sched) if (job && dma_fence_is_signaled(&job->s_fence->finished)) { /* remove job from pending_list */ list_del_init(&job->list); + + /* cancel this job's TO timer */ + cancel_delayed_work(&sched->work_tdr); /* make the scheduled timestamp more accurate */ next = list_first_entry_or_null(&sched->pending_list, typeof(*next), list); - if (next) + + if (next) { next->s_fence->scheduled.timestamp = job->s_fence->finished.timestamp; - + /* start TO timer for next job */ + drm_sched_start_timeout(sched); + } } else { job = NULL; - /* queue timeout for next job */ - drm_sched_start_timeout(sched); } spin_unlock(&sched->job_list_lock); @@ -791,11 +789,8 @@ static int drm_sched_main(void *param) (entity = drm_sched_select_entity(sched))) || kthread_should_stop()); - if (cleanup_job) { + if (cleanup_job) sched->ops->free_job(cleanup_job); - /* queue timeout for next job */ - drm_sched_start_timeout(sched); - } if (!entity) continue; From patchwork Tue Aug 31 10:35:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liu, Monk" X-Patchwork-Id: 12466897 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,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 E7BA5C4320E for ; Tue, 31 Aug 2021 10:35:59 +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 B1FBE601FD for ; Tue, 31 Aug 2021 10:35:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B1FBE601FD Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EC4A189AF3; Tue, 31 Aug 2021 10:35:57 +0000 (UTC) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2082.outbound.protection.outlook.com [40.107.237.82]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1AA5289A76; Tue, 31 Aug 2021 10:35:56 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gClb1cyd+JI+VyyqlIShsnscHMUWDEc0s9ZnRvMFtKpARNAAxwzkKJAriphbRoaGHZlsp5QfaLWn1sw0Diw+QOJGBZZjA7UZsfF3LEvIqf81vyY4OUxJidEIU4Dg48ij8GvWZIBzpI0oZS82h3y1bl4TLGH4vZI6D42ygZ8JyR2gtR4T7E/resAmSUMp2kSwZ1jbYR7m1rJL52Y+SDkj+IFq9MGiN7WaSry9AC2mT/Q++pxDxJ9+A22owfKo4+L5eR5akCp9Ko75KeT1k1akt7DWCnZyXuOU8Gx/2J33lp/t6Gnx3h737F6XhsCHNul48Uo3eWnzA6sX2kDu5Oqyaw== 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=+hfU2lFbTyWfIjkrWVPJwBFQGH/b/4syvDRFIkT8Wc0=; b=CVGnX3aOxCGUjDYKCKoVNyZPGblE9C4+kAUnDM1t2aFKQHokN5BldkGgYJLt++RZbVmKcn93G7M/Og6Vq/UxihggF67esqq0ObQ03q+q4fk0DU3pWmPGz+7sEjKtFG/4gOmtHqxtFV+yiFKEQw+gyjcwwjnSLnb0HFrjnEg/r5rObWamYF6RfvKA7aSgNA3lYp+0933Z1axyzftV1THiEhx4BFhA3Es+wcDdyB48dWrLDQfW9E66GJVcG98annDgtgQlMDNDoEEL2keifDUFXBZ+EWGBYKC3aEaGPqgO7B2fgefMgMxul5v13+LKUZIt3a4Vd46UkPv3Syk9EPbTWQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+hfU2lFbTyWfIjkrWVPJwBFQGH/b/4syvDRFIkT8Wc0=; b=T8hpViN/8I/FCy9jgAFaAsu8IR21xgNtNse22d5F3E2XF453OJ8BAp7MRe+oHqfUvE8cirapk9SA9Kp7A9OvCv4BxKdByGeF95OA7XibCvkBQb4L8PzYw1Vi5aSlZvNauZaEAptgw/75nqJyOgc6QDVeuS2amEmHzHbLM4h4U7w= Received: from MWHPR01CA0041.prod.exchangelabs.com (2603:10b6:300:101::27) by DM5PR12MB1932.namprd12.prod.outlook.com (2603:10b6:3:10e::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.18; Tue, 31 Aug 2021 10:35:49 +0000 Received: from CO1NAM11FT010.eop-nam11.prod.protection.outlook.com (2603:10b6:300:101:cafe::1) by MWHPR01CA0041.outlook.office365.com (2603:10b6:300:101::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.18 via Frontend Transport; Tue, 31 Aug 2021 10:35:48 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; lists.freedesktop.org; dkim=none (message not signed) header.d=none;lists.freedesktop.org; dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT010.mail.protection.outlook.com (10.13.175.88) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4457.17 via Frontend Transport; Tue, 31 Aug 2021 10:35:48 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12; Tue, 31 Aug 2021 05:35:46 -0500 Received: from monk-build.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2242.12 via Frontend Transport; Tue, 31 Aug 2021 05:35:45 -0500 From: Monk Liu To: CC: , Monk Liu , "jingwen chen" Subject: [PATCH 2/2] drm/sched: serialize job_timeout and scheduler Date: Tue, 31 Aug 2021 18:35:39 +0800 Message-ID: <1630406139-19621-2-git-send-email-Monk.Liu@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1630406139-19621-1-git-send-email-Monk.Liu@amd.com> References: <1630406139-19621-1-git-send-email-Monk.Liu@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 44b2abc8-a0b5-4a5e-6fb3-08d96c6b1919 X-MS-TrafficTypeDiagnostic: DM5PR12MB1932: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ehIoXFVAPR7vECwngjFOPE/ZLQhN59e/YD0ydRhVdbii89Jm7OzQhSIol9IcfSs+w4/NxqOLL0Eytg5UVSq83v4XITAa12+gUcDYf3fqsX3Q9/jUd2Ptm+LVGKBHAqsHJAs+71ad2x9MR44Jf41vb1W44om2sc74dIPjHWSsIi4tgMChj+ZoEopXaPft76Co7ke6/b1JjGsOCGl1w2vl9gDJ88Aski3xnDU+/fy1JyEuDeTQuZZ9y5A8z1Tw60SG6FLx9wNYHJOpPoSm+PB3wPIAWaUZA+gKhgbrdIWal2AKEYfnAKkTY7PF32iBLfNo2PKXadtlHLB8qz5fzKlOYMFT2f90HXyGz7v5cqByA8GYhZ5MUYuHIGi3tnfiSWQcPd/4iLh4nE0cRsigm3SurvqvaAoson+EQtvw76hHp5spi5mDNE3jn8z8idfF3RViDawldFLHttB8OgJkVsSnlOr23fLctkIr+iln6uhdKXOD8s56lk1kKK7aXP9HeMQQahpZ+Vw7W1a8L2Elt9wL7Lws5T4u2OXsiMjhfRnfy57ir6J3R7bIzNAjC4biTJ+9gqnMLBdZip4sGMd6Yff426jnpg26+m7QmqpvQt8ELIH+ynLTZNm6PKUK7Uhu5eKmPdkl7mGXYSk/FitgxEDk+ktTo7G68xXPIUa134Zj+ZDdtBI8XMWjy7qSf0zAlU+j7f1ItkyIuaMc7JxluaoFbS5oQSw6Wxcp+9bGYhofLIw= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(4636009)(346002)(39860400002)(376002)(396003)(136003)(46966006)(36840700001)(4326008)(81166007)(186003)(2906002)(356005)(82310400003)(478600001)(36860700001)(2616005)(8936002)(6666004)(26005)(82740400003)(426003)(336012)(83380400001)(47076005)(8676002)(70586007)(70206006)(6916009)(7696005)(450100002)(36756003)(86362001)(316002)(5660300002)(54906003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2021 10:35:48.6324 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 44b2abc8-a0b5-4a5e-6fb3-08d96c6b1919 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT010.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1932 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" tested-by: jingwen chen Signed-off-by: Monk Liu Signed-off-by: jingwen chen --- drivers/gpu/drm/scheduler/sched_main.c | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c index ecf8140..894fdb24 100644 --- a/drivers/gpu/drm/scheduler/sched_main.c +++ b/drivers/gpu/drm/scheduler/sched_main.c @@ -319,19 +319,17 @@ static void drm_sched_job_timedout(struct work_struct *work) sched = container_of(work, struct drm_gpu_scheduler, work_tdr.work); /* Protects against concurrent deletion in drm_sched_get_cleanup_job */ + if (!__kthread_should_park(sched->thread)) + kthread_park(sched->thread); + spin_lock(&sched->job_list_lock); job = list_first_entry_or_null(&sched->pending_list, struct drm_sched_job, list); if (job) { - /* - * Remove the bad job so it cannot be freed by concurrent - * drm_sched_cleanup_jobs. It will be reinserted back after sched->thread - * is parked at which point it's safe. - */ - list_del_init(&job->list); spin_unlock(&sched->job_list_lock); + /* vendor's timeout_job should call drm_sched_start() */ status = job->sched->ops->timedout_job(job); /* @@ -393,20 +391,6 @@ void drm_sched_stop(struct drm_gpu_scheduler *sched, struct drm_sched_job *bad) kthread_park(sched->thread); /* - * Reinsert back the bad job here - now it's safe as - * drm_sched_get_cleanup_job cannot race against us and release the - * bad job at this point - we parked (waited for) any in progress - * (earlier) cleanups and drm_sched_get_cleanup_job will not be called - * now until the scheduler thread is unparked. - */ - if (bad && bad->sched == sched) - /* - * Add at the head of the queue to reflect it was the earliest - * job extracted. - */ - list_add(&bad->list, &sched->pending_list); - - /* * Iterate the job list from later to earlier one and either deactive * their HW callbacks or remove them from pending list if they already * signaled.