From patchwork Wed Nov 6 17:51:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrey Grodzovsky X-Patchwork-Id: 11230795 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D0B161709 for ; Wed, 6 Nov 2019 17:51:29 +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 B828C214D8 for ; Wed, 6 Nov 2019 17:51:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B828C214D8 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3A9666EE1F; Wed, 6 Nov 2019 17:51:26 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM05-CO1-obe.outbound.protection.outlook.com (mail-eopbgr720053.outbound.protection.outlook.com [40.107.72.53]) by gabe.freedesktop.org (Postfix) with ESMTPS id 225526EE1F; Wed, 6 Nov 2019 17:51:25 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c719iaRK1GH/MSwFvxCyDpiTsLC20dgyHNG+JmIRa4j6vJjVMil+171PMVo5HRg8+mZ3CrCwtFeAfvz28d8nG2NrTCLbBFmcpFbbg4MFre1E3UjVzY7cWjPv+cRbhygMleekbs0IOPZ2Oh9nn0PhNARKbnKc5zb2JbAnycU++lpcVocq8XORsCLW6ZqFli1ov9jBB4fdzTLmFjHRP4bvW9L2JAyNxJYACpkFkqhNlS3oM8i5gRjoqgiYjP4MVgsyfBnkzGDaNDTnXZuV9c0zl/NgAxyzMw8O7ne/jvIBcCkVFGIeUvkNjiPCS61acp8rO9ejMoaVJnem9ELhyHbBvA== 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=qN6DK+9nA7jgfoJ6aBZVsikV50p3nwbBfPIs1xM8cHs=; b=SvI9TGy407CoAORwfh74I/mOrJ5py0WsqEtBqLls1Cj1Akcsn9Z/39G559LzilVOdbCIoqv8QcEYJ3Q1lAGPQWtBVV52k45zRNpdbG/eiPer4aSBrwN6t5O8CPeK9nguQW8mUv6Y2yy/4xDQTlV8/VCMxIiZ908rGCDLi4KZ0fZvnq6x0mZLms5tCo93qK5lJ2YCPtTxNY8M3QX5lBUqNMcih91hqHM76tgg6zMR0adRNYVRBWM8ZZcFvjnl1+TzxOJAnQCPTJtGxtlq6wbcAtVA7LPVgnXJJHFNzkE2HeFH1r2B90w/5fOUg6+KBkN0OCSI3TKjk3kuJF7dT1klHA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=amd.com; dmarc=permerror action=none header.from=amd.com; dkim=none (message not signed); arc=none Received: from DM3PR12CA0077.namprd12.prod.outlook.com (2603:10b6:0:57::21) by BYAPR12MB3621.namprd12.prod.outlook.com (2603:10b6:a03:db::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2408.24; Wed, 6 Nov 2019 17:51:19 +0000 Received: from DM3NAM03FT007.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e49::200) by DM3PR12CA0077.outlook.office365.com (2603:10b6:0:57::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2430.22 via Frontend Transport; Wed, 6 Nov 2019 17:51:19 +0000 Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from SATLEXMB02.amd.com (165.204.84.17) by DM3NAM03FT007.mail.protection.outlook.com (10.152.82.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.2430.20 via Frontend Transport; Wed, 6 Nov 2019 17:51:19 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) by SATLEXMB02.amd.com (10.181.40.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Wed, 6 Nov 2019 11:51:18 -0600 Received: from SATLEXMB01.amd.com (10.181.40.142) 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.1713.5; Wed, 6 Nov 2019 11:51:18 -0600 Received: from agrodzovsky-All-Series.amd.com (10.180.168.240) by SATLEXMB01.amd.com (10.181.40.142) with Microsoft SMTP Server id 15.1.1713.5 via Frontend Transport; Wed, 6 Nov 2019 11:51:18 -0600 From: Andrey Grodzovsky To: Subject: [PATCH 2/4] drm/sched: Use completion to wait for entity idle Date: Wed, 6 Nov 2019 12:51:10 -0500 Message-ID: <1573062672-23698-2-git-send-email-andrey.grodzovsky@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1573062672-23698-1-git-send-email-andrey.grodzovsky@amd.com> References: <1573062672-23698-1-git-send-email-andrey.grodzovsky@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:165.204.84.17; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(4636009)(396003)(39860400002)(376002)(136003)(346002)(428003)(189003)(199004)(476003)(47776003)(70206006)(2906002)(23676004)(53416004)(7696005)(5660300002)(5820100001)(2870700001)(50226002)(44832011)(478600001)(70586007)(66574012)(4326008)(109986005)(305945005)(86362001)(446003)(11346002)(126002)(2616005)(81166006)(14444005)(81156014)(8676002)(8936002)(356004)(6666004)(336012)(186003)(54906003)(76176011)(316002)(50466002)(426003)(486006)(36756003)(26005)(1671002)(450100002)(266003); DIR:OUT; SFP:1101; SCL:1; SRVR:BYAPR12MB3621; H:SATLEXMB02.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoDomainNonexistent; MX:1; A:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1f059255-51af-48f8-3c4e-08d762e1eddf X-MS-TrafficTypeDiagnostic: BYAPR12MB3621: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-Forefront-PRVS: 02135EB356 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: R38ZRiTVfq4y84jErvE4g5yQS6WnKYAp/CZ50bKWkwyZY9bC2CrqMgh8xh2ck9eIy3LwZpqUuQllu10rX7CxLOJ6uwf/HruV+qt7v3UOq8SgSJZzWm3sdIDQeCCxLn0AFQ4M60eeeuqpwu0vF1fZF5PEjlRunsD7/BXyONeLEsQVc/uTqQm3MV1LUeYkNBWdPi4RE5PaRdQfFhCkBtZOtET+2vIsK5wlXo0qIJTXHNkSIyyD0vm7rNLxfsvQLH668YAInvN/lvBKhU2keHIOEQy0eNFq2KqUYTvvlgJlP+Z84t1oRkbpEc1dwnZI5ClitdFeYOeoyGTIIp6A8aUCvGoJcWY4sziSL1F3u/+XJz/BBAka6rjvs13dh1Q0Mu9pN2Rkxc+raaR0Js4kgaAoxN9o9HSbYxYM8mqOsoI9ybsQNxTWHl8kWNaRdOmDWy8I X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Nov 2019 17:51:19.3357 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1f059255-51af-48f8-3c4e-08d762e1eddf 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=[SATLEXMB02.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB3621 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qN6DK+9nA7jgfoJ6aBZVsikV50p3nwbBfPIs1xM8cHs=; b=Ur5KyELO+TkbSdzIlorMKZwbIMhczNaeiJtqRApnB0lrFWCIKh+7kLTpiSplIRiH5BoNet/qQTg5Pfta5UpyVkLT8LTiUwgux24Dccxiw6smpD5GHmlld3pcR/h6MsQLOYyqhlP+i8AGE8QrXCEJ8nyFQWIDpzQWV5hm9qb/ODE= X-Mailman-Original-Authentication-Results: spf=none (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=permerror action=none header.from=amd.com; X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Shirish.S@amd.com, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, Christian.Koenig@amd.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Removes thread park/unpark hack from drm_sched_entity_fini and by this fixes reactivation of scheduler thread while the thread is supposed to be stopped. Signed-off-by: Andrey Grodzovsky Suggested-by: Christian König --- drivers/gpu/drm/scheduler/sched_entity.c | 12 ++++++++---- drivers/gpu/drm/scheduler/sched_main.c | 6 ++++++ include/drm/gpu_scheduler.h | 2 ++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/scheduler/sched_entity.c b/drivers/gpu/drm/scheduler/sched_entity.c index 1a51531..461a7a8 100644 --- a/drivers/gpu/drm/scheduler/sched_entity.c +++ b/drivers/gpu/drm/scheduler/sched_entity.c @@ -23,6 +23,7 @@ #include #include +#include #include #include @@ -68,6 +69,8 @@ int drm_sched_entity_init(struct drm_sched_entity *entity, if (!entity->rq_list) return -ENOMEM; + init_completion(&entity->entity_idle); + for (i = 0; i < num_rq_list; ++i) entity->rq_list[i] = rq_list[i]; @@ -286,11 +289,12 @@ void drm_sched_entity_fini(struct drm_sched_entity *entity) */ if (spsc_queue_count(&entity->job_queue)) { if (sched) { - /* Park the kernel for a moment to make sure it isn't processing - * our enity. + /* + * Wait for thread to idle to make sure it isn't processing + * this entity. */ - kthread_park(sched->thread); - kthread_unpark(sched->thread); + wait_for_completion(&entity->entity_idle); + } if (entity->dependency) { dma_fence_remove_callback(entity->dependency, diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c index dba4390..38bbad7 100644 --- a/drivers/gpu/drm/scheduler/sched_main.c +++ b/drivers/gpu/drm/scheduler/sched_main.c @@ -47,6 +47,7 @@ #include #include #include +#include #include #include @@ -134,6 +135,7 @@ drm_sched_rq_select_entity(struct drm_sched_rq *rq) list_for_each_entry_continue(entity, &rq->entities, list) { if (drm_sched_entity_is_ready(entity)) { rq->current_entity = entity; + reinit_completion(&entity->entity_idle); spin_unlock(&rq->lock); return entity; } @@ -144,6 +146,7 @@ drm_sched_rq_select_entity(struct drm_sched_rq *rq) if (drm_sched_entity_is_ready(entity)) { rq->current_entity = entity; + reinit_completion(&entity->entity_idle); spin_unlock(&rq->lock); return entity; } @@ -721,6 +724,9 @@ static int drm_sched_main(void *param) continue; sched_job = drm_sched_entity_pop_job(entity); + + complete(&entity->entity_idle); + if (!sched_job) continue; diff --git a/include/drm/gpu_scheduler.h b/include/drm/gpu_scheduler.h index 57b4121..6619d2a 100644 --- a/include/drm/gpu_scheduler.h +++ b/include/drm/gpu_scheduler.h @@ -71,6 +71,7 @@ enum drm_sched_priority { * @last_scheduled: points to the finished fence of the last scheduled job. * @last_user: last group leader pushing a job into the entity. * @stopped: Marks the enity as removed from rq and destined for termination. + * @entity_idle: Signals when enityt is not in use * * Entities will emit jobs in order to their corresponding hardware * ring, and the scheduler will alternate between entities based on @@ -94,6 +95,7 @@ struct drm_sched_entity { struct dma_fence *last_scheduled; struct task_struct *last_user; bool stopped; + struct completion entity_idle; }; /**