From patchwork Wed Sep 1 00:46:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Liu, Monk" X-Patchwork-Id: 12468023 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,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BC3BBC432BE for ; Wed, 1 Sep 2021 00:46:56 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5320C60525 for ; Wed, 1 Sep 2021 00:46:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5320C60525 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 AF40D6E042; Wed, 1 Sep 2021 00:46:55 +0000 (UTC) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2070.outbound.protection.outlook.com [40.107.237.70]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1AED3898A7; Wed, 1 Sep 2021 00:46:53 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eG8RnNo5z/XTdaKOavgnCeH9PwrDbCUsWfxLlL9fGlcp9RqDEaR83ci443dTKG5yRV/5ITI+tmZaCJ/J+qZFb1VaIYr9dgG5S3zOyx5au2D+xzQthp4gPLbg/oFRmMHHE10QgyCBaAIYQ6S9YAInldTMeAt1raQenWf9E1FNSRmn7cfLShDuQ2qa+CrgODZiVbZyTb7NaE6HPHu4gpx8/Jn26rV8DojVc/Z6M0GCxO+LCDfYbMaSFqaI/laj+YyBhM1PnI/w3qsa7ketQqsqynYMdan+qPAoMj5qYFo/NU6XLvgSdM4zVMLaFTNDTBUA0R350IOACo6P5dxWmnLsGg== 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=ntmg9JFadsEkkzdZuIdnd5quzh65EWasqA9+fVv/UaM=; b=NHGz8rNLm7XdrZ6RKouul/2W8GhPhSiteYbswnjEQF1jO7TFJSFz/Utvau9bIB2YIcBrfntaykm10EEosKG+oxggHCLsHKNjymIuuzEUhj7YWEAgxE1Y8p8xeTlM+VScvJI01poD3KT4ydZ3u3rELU+KPV5OwsfspTuyT6giGiMWVIInOKbo+QXA1+Wmpldczn1LwGjiOQN9c6afCALcsGAWC/Br0JlF947ySn58NSvftnH72BqFWcXEZyEqkpSz2CVTmfu02g6LLbd/zLnKxodk2tGBiq67oCVRGoCD9gCjJZBH5jx3b5JSXFMxw86zKEIQAS2RRTh4sVmYkN8UDw== 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=ntmg9JFadsEkkzdZuIdnd5quzh65EWasqA9+fVv/UaM=; b=STm5TwmxxkCl109W6zBbBpTbyABIT/Ewb6LAP+UckAy/VgtbnaJHLyvyZgd9aerQq9oY+qoHnHFswDoZIMzS2kXzyETIVaWQNzSRyGb56Rh2mQUtFGthWXC4vOgzy3tM59X/iXLwxB2QKi9mk1xw6BZiQfBVYYRaNJHRTM0Z5p4= Received: from BN6PR11CA0016.namprd11.prod.outlook.com (2603:10b6:405:2::26) by CY4PR1201MB0166.namprd12.prod.outlook.com (2603:10b6:910:24::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.23; Wed, 1 Sep 2021 00:46:51 +0000 Received: from BN8NAM11FT054.eop-nam11.prod.protection.outlook.com (2603:10b6:405:2:cafe::9b) by BN6PR11CA0016.outlook.office365.com (2603:10b6:405:2::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.17 via Frontend Transport; Wed, 1 Sep 2021 00:46:51 +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 BN8NAM11FT054.mail.protection.outlook.com (10.13.177.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4478.19 via Frontend Transport; Wed, 1 Sep 2021 00:46:51 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) 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 19:46:50 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB06.amd.com (10.181.40.147) 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 19:46:50 -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 19:46:49 -0500 From: Monk Liu To: CC: , Monk Liu Subject: [PATCH 1/2] drm/sched: fix the bug of time out calculation(v4) Date: Wed, 1 Sep 2021 08:46:46 +0800 Message-ID: <1630457207-13107-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: 913dfe95-2cc6-4a29-971d-08d96ce1fc99 X-MS-TrafficTypeDiagnostic: CY4PR1201MB0166: 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: oo47Tx0uUajQKnmR2g7NtRtit3EIvYjM3uXFX7YE+2k7YDiIxIGCGcbmOkBA4U2X4iOuB1AL/mXHTlwaWKWpLEpAxBAKy8zyw67m2++M6lmXo0x6id2eIYfieJq9+0wbwAR6dPTAAHdRvk0xcHgQHK2ac1yCkc2N3s6kTUTOsUAImQMjmLmTGOBHq16gs4MIKv1odYWEmHyugLSwhzwuHuUDfaMIXiyDzo8+/h5Ct3mDC/u26imcKpLKwumSYVAyxpwcNEaF4PnUc9qYapjjDyP7d9iND1EQKXmvofw77+aUPd9SMsaVpqY4izsoV4Ef/SwPrZwgnQajOem6llsbo6o/KXS7F1jmZtt1efwrhiEeiIWIE/MLLWYQ9mxZA1+TZt5DUObHuKjWFjxAbyTQKnSpQRPTpOrXfJklo3bCcOmvn7RbwIcAp56aDa5FQUUSSCV8QIvFPnB5IU7GTfw9mOby5+jYBSSdqgPv4TP1l9UtXM0ytIAgTmnxOHxC7lwbG1pI0TV6pAy8rHmdEXsdkX6by+RF4fWACtT3rY1oYtdi/H+N1QNB6r3KzW14GVKi6B5sS/r6876dccO/mryHKf6C29ExCUSsx4IiDhcZMtlQQExcgj161wBiEUAkAXgbYKyiHTqlqcuwAe27BmICZb10VOLLfCXJcluSc1PgdP4dJumQiFhoJc6Jht4bWeNmhu9IYuxjEfw1CqSGKL/+OeYLLdqE2fq3afcTYrVHG+g= 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)(39850400004)(376002)(396003)(346002)(136003)(46966006)(36840700001)(86362001)(4326008)(83380400001)(36756003)(47076005)(82740400003)(2616005)(36860700001)(356005)(82310400003)(2906002)(81166007)(450100002)(54906003)(186003)(7696005)(5660300002)(70586007)(26005)(426003)(8676002)(6666004)(478600001)(316002)(8936002)(6916009)(336012)(70206006)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Sep 2021 00:46:51.0571 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 913dfe95-2cc6-4a29-971d-08d96ce1fc99 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: BN8NAM11FT054.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR1201MB0166 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. v4: remove the kthread_should_park() checking in cleanup_job routine, we should cleanup the signaled job asap 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 Reviewed-by: Christian König --- drivers/gpu/drm/scheduler/sched_main.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c index a2a9536..3e0bbc7 100644 --- a/drivers/gpu/drm/scheduler/sched_main.c +++ b/drivers/gpu/drm/scheduler/sched_main.c @@ -676,15 +676,6 @@ 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()) - return NULL; - spin_lock(&sched->job_list_lock); job = list_first_entry_or_null(&sched->pending_list, @@ -693,17 +684,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 +786,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 Wed Sep 1 00:46:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liu, Monk" X-Patchwork-Id: 12468025 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,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5EC9AC432BE for ; Wed, 1 Sep 2021 00:47:03 +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 2A31360525 for ; Wed, 1 Sep 2021 00:47:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2A31360525 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 6A9846E0F7; Wed, 1 Sep 2021 00:47:00 +0000 (UTC) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2073.outbound.protection.outlook.com [40.107.220.73]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4EE5B6E0F7; Wed, 1 Sep 2021 00:46:59 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ml/nBUS3YjBP5sfJUUJdB4cZpUa/h6zz34ZCYI1KVPb1W9VTSF03CE67KzcL8dJxzpoBzdYfH/Agu5ynvwfPGH51vxVwUGzJqpm8D8tZlPT0buo1UrjzWH/yVcg2mGdyqM50SwEnBbjYoWNPaySlVAwjXW9s/3CmP/+uDuVWvU9T/l3nfB0HhYFf9bNv0OMCTDQoL5RT4O2pRLtc44zppIoulG0HoDudNB5qOv7FeowN4USOkF03ryRiWAxmYm1lNhdrvWdY6aC+y4CoK9hKefFb1xLzf5wj5NuVq8elZ9iM5nFpI4W5DC6cGtsMjlaP725qeQgUejamgU6yxAhiXQ== 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=vI0QMkDR/5LooxrvJ54ekyY9qsIiLG4HQyIqmyriF2Y=; b=i9UVKL7Hjo/Y5f+wKwigzWeH0+H6OuuhoydNTtRPsV38eHnBofmO//INh1Omy4DTKQRaktCr4afFGm+kv4yBdclrPfTN0vQUvG2sW7arYrQrP+rMoGQnwiet9Tk4lPr2tMdhVpKUZIUc5lg9NQSQo1bF5EJabUSt684XT3ijdOjB1eXF3d7Uxwh40qYpZYQcw6Z5UKMkUaOJrcAe2W/n7hpF6ORaC3uEjnnGIeqtQAAl9SFy8i+Zmvn0VnGToTkmR2eMLr9ga9p6AcVWxPbhXhRXdtj69cYYvZdReb4Vo0+CQ+4lWVPeerQ7/cHHAkzOxbmd652JaG9N3uPsdQBW8Q== 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=vI0QMkDR/5LooxrvJ54ekyY9qsIiLG4HQyIqmyriF2Y=; b=ElyV6/VKb8jTgQKiwngAxC1PIUx+MFNQUmuwqTGqbSp6uZI+NoUauNC/Kg0Hb130cppBSYNbaLjXhzbBgUns3QfbXvZ6eNs7whrj523TCk1JZG8bKGhoAAqoNjod4kH+L061atpb7tcNQws0EolWiSnO4rRofZcagW7N7BAVjtI= Received: from BN9PR03CA0544.namprd03.prod.outlook.com (2603:10b6:408:138::9) by CH2PR12MB4229.namprd12.prod.outlook.com (2603:10b6:610:a5::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.23; Wed, 1 Sep 2021 00:46:57 +0000 Received: from BN8NAM11FT064.eop-nam11.prod.protection.outlook.com (2603:10b6:408:138:cafe::2a) by BN9PR03CA0544.outlook.office365.com (2603:10b6:408:138::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.18 via Frontend Transport; Wed, 1 Sep 2021 00:46:57 +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 BN8NAM11FT064.mail.protection.outlook.com (10.13.176.160) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4478.19 via Frontend Transport; Wed, 1 Sep 2021 00:46:56 +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 19:46:52 -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 19:46:50 -0500 From: Monk Liu To: CC: , Monk Liu , "jingwen chen" Subject: [PATCH 2/2] drm/sched: serialize job_timeout and scheduler Date: Wed, 1 Sep 2021 08:46:47 +0800 Message-ID: <1630457207-13107-2-git-send-email-Monk.Liu@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1630457207-13107-1-git-send-email-Monk.Liu@amd.com> References: <1630457207-13107-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: 80c38126-eb33-4a59-ee13-08d96ce1ffe6 X-MS-TrafficTypeDiagnostic: CH2PR12MB4229: 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: OQbBkwDFoiuo4tXqP8QAoe1FhnNgZe2LbjDFdc7gXjkn1CSFHjaQ3SxcgirjnAkkg0M+ci4b1zokLvM/crXGT8g5D9OloZsXOFCSYIl+sdrXwMCV369SsuYXjpOY1lt37NrQ+uOW1CtXbsKgmsly006ovXNRJycLXlyZ2dD3ibrXGJldEVhS1teara/IOpiG9D0zyjHmfPbywRBoSmG4T2B2ITPvZYnWdT5WYhocj0AJqK8oOtZGeKQjyy1GeYOQiaGYYjTkySO0yl38+TWseRxe4jRdQDacE8zB3CLKn4dWyvUIIwaIxZtDbMpk4XHRdeznLqwvmnO0Myv9Iv5M9ada6RajJi1h0z6/UFog9VXBypPDfgf3padBBVoG2W8VSwJnUpfg5zmlxXpvs9MJECq3TL7XGWFTzwOBakfKboln8I4qgcuh6xnCW/9Au7jL3hUrnM7Xp6xjmiHnJ80OBvyXIMN98cigefDRrwuyrporj9Ps20EGuGpCOLTtrHKXyZ5AvKevgpL2zi/4v0xRubWnwmWcm4YFc8UIsrLz4l/0DYcYF69OpS3bB7yggHhiGRP8i/2xLOMEgFfXtqmz97ibWoOgLJ2akx6Gymo4a+8vTHzxbjCU5ute4o+rIi18jg2Sn/3XPbMUrY+J6MWlUOEKKw9XAXGGkwiR6XAjYWy34EKZkEEQ6j1/scpfemCpNUrqok8vIHk/KXJ9+FVjK7GcshghDufkPMYmNb+w+eA= 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)(376002)(39860400002)(396003)(136003)(36840700001)(46966006)(26005)(478600001)(2906002)(47076005)(83380400001)(356005)(81166007)(82310400003)(36860700001)(6666004)(7696005)(186003)(36756003)(426003)(70206006)(70586007)(82740400003)(2616005)(4326008)(54906003)(450100002)(316002)(86362001)(336012)(6916009)(8676002)(5660300002)(8936002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Sep 2021 00:46:56.5951 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 80c38126-eb33-4a59-ee13-08d96ce1ffe6 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: BN8NAM11FT064.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4229 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 3e0bbc7..87d72e9 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.