From patchwork Wed Oct 24 17:07:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Grodzovsky X-Patchwork-Id: 10654811 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4628914BB for ; Wed, 24 Oct 2018 17:08:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3099C2AE35 for ; Wed, 24 Oct 2018 17:08:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 249AA2AF06; Wed, 24 Oct 2018 17:08:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 661AB2AE35 for ; Wed, 24 Oct 2018 17:08:06 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F1F606E247; Wed, 24 Oct 2018 17:08:03 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM02-BL2-obe.outbound.protection.outlook.com (mail-bl2nam02on060f.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe46::60f]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0B7536E247; Wed, 24 Oct 2018 17:08:03 +0000 (UTC) Received: from BN6PR12CA0038.namprd12.prod.outlook.com (2603:10b6:405:70::24) by CY1PR12MB0742.namprd12.prod.outlook.com (2a01:111:e400:59d1::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1250.30; Wed, 24 Oct 2018 17:08:00 +0000 Received: from DM3NAM03FT038.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e49::202) by BN6PR12CA0038.outlook.office365.com (2603:10b6:405:70::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1273.18 via Frontend Transport; Wed, 24 Oct 2018 17:08:00 +0000 Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from SATLEXCHOV01.amd.com (165.204.84.17) by DM3NAM03FT038.mail.protection.outlook.com (10.152.83.95) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1273.13 via Frontend Transport; Wed, 24 Oct 2018 17:07:59 +0000 Received: from agrodzovsky-All-Series.amd.com (10.34.1.3) by SATLEXCHOV01.amd.com (10.181.40.71) with Microsoft SMTP Server id 14.3.389.1; Wed, 24 Oct 2018 12:07:56 -0500 From: Andrey Grodzovsky To: , , Subject: [PATCH v4 1/2] drm/sched: Add boolean to mark if sched is ready to work v4 Date: Wed, 24 Oct 2018 13:07:48 -0400 Message-ID: <1540400869-17930-1-git-send-email-andrey.grodzovsky@amd.com> X-Mailer: git-send-email 2.7.4 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)(376002)(346002)(396003)(39860400002)(136003)(2980300002)(428003)(189003)(199004)(86362001)(316002)(68736007)(97736004)(476003)(54906003)(110136005)(126002)(51416003)(16586007)(104016004)(7696005)(53936002)(2906002)(50226002)(47776003)(6636002)(6666004)(356004)(5660300001)(8676002)(8936002)(305945005)(81166006)(81156014)(36756003)(486006)(4326008)(44832011)(105586002)(426003)(53416004)(2616005)(450100002)(478600001)(186003)(2201001)(48376002)(77096007)(50466002)(26005)(575784001)(336012)(106466001)(72206003)(14444005); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR12MB0742; H:SATLEXCHOV01.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoDomainNonexistent; MX:1; A:1; X-Microsoft-Exchange-Diagnostics: 1; DM3NAM03FT038; 1:qj82LVNTIOVMzWezRq5oZ3JTyBJesbk3lYmfygBYHgPZDuwAyYF/CEkjSpFYnHbTHYnFjen5m7VyPK9P9wO8Ufz6mT7X4lOTJBHSZ5qZAkuFxpQBWUziEfrfTN4T+v24 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 43104191-62dc-40ff-f0de-08d639d34055 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(5600074)(711020)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060); SRVR:CY1PR12MB0742; X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0742; 3:a9wOpBnutDtX8/4dAfbU88IpguRVEck/2XWvZbxX3SNTSXrewAV0dxF2quTcfduI46XjM0DVVq5MQpZlSm657ER0VP5zLW5e7ifrymIAVfOJ7KFnYJqFX1w+0xvIBxybgNaU/TXeZzC6Tkc8K6NeMR1fjCTf2C+IosyZYn8oVdvGR0MlFztH96vBp65Qj5hgpf+gVtxK0Ag4o9biU1Ryz7vYzZSCM7Gg/mwZavhBtQJs+UthLBI63ip+YzofAFUcZGHJ61R692gsgPnLpQZLCioux1dWLxWiEXx6leDVwneA90Usdpc7wzRnUwJ16bdDKNahRh3B3a8YOP06piiQ6wMls2T3PtUJ4q5EuG6oBYo=; 25:Qfg8ffU2ME8/am6yUL2HIwiL723SckQhcBaR4UsoDI/R4Ctocc9e5Cy/djnz08OL47QQ1IHffSJ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ZEh0NEM/sLZCA2uGEHLmn+lYGgId X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(93003095)(10201501046)(3002001)(3231355)(944501410)(52105095)(6055026)(148016)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201708071742011)(7699051)(76991095); SRVR:CY1PR12MB0742; BCL:0; PCL:0; RULEID:; SRVR:CY1PR12MB0742; X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0742; 4:wMESULbYMAGQerV05t2qtTTD607rDw/S+j2DkmDfUJ2xCw+nxahYntGIEt/mG9Dh1beKssod3A34NwzDitVGhgs0aoB8M/7Dee3yYoe7x8gBSK5f5Gjg+mj3DR3rqcQAMZ7AAk0MKqyhd7UaMMPhp/HoN/uZEHLfpVKHJItwNAzh+o6Qy9puQlp/BelQ7vB3jz259ZBfjG6fUiC3SBpSa3I5sXGUPgcb3legyg59qNKSyOhcYJdc1HYMViy2NDmbXCKJH+O+t6yGU0Bagkao+ZVVO73mUvfJSmAtB/LzGuijrx1MIsy87gdMsvxZFiTU X-Forefront-PRVS: 083526BF8A X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR12MB0742; 23:QmUFdym9Jri1bci7p34poZ9s4pqqANgYvlZoJrva+?= ybvRN8hbhDHT6rgW618+Caz3yqGMdRa2hMr8EbWBHX6pYeuKFZZYWrgXt21/WcNKumkZWIdWFtSkX5SnCQAQkdTh6KP9xuJ6wkCbCPWPUgX83xBymmLHwlds6cxFXmx5yRNj0aZMEr1tC4fy2rh4zoD8PuSoN1LsmbvzyeMezNVIjMCquW8cmT5mti1yjilLQ7lEg5frgTFFV4yXFxNHL8nuZLy5FqIDvPq4oEQsueDJEyXB3z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QpWcTSgie+BIVnuuh33TfNbO8rK/5pSpx6wkK4HtMR01vP9YKv/29OLWzYJGaGSYnXWZM9smakswmMyzY8GRnDGVyJ3MESbqZ58jrT/aIqp0GJ75p7nGlCXKOT1 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0742; 20:ZMq8eXWIFqLjEOobiMRv8YBQRbXEN/4mDzokMXZlG+lr6wxXSwNgsnY8SPgjLv73YrpAb1cs1T8MPlXm0epvrzJQltALZfTCyYybcbxMlavE8ZpL7+3QPDVOficpZ5aTyEpGdZeztpdVJmuhOe6UAjbDRvU9/2qP2i3QX49kDz+sMTpvJhZPqY/DgqBdOrJrz/K41q4YExwkRdWUsLo2RxSsSvyqj3gfsF3BPH8NdZt8t/sAAhgdQzW/fvqGRT7h X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Oct 2018 17:07:59.6791 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 43104191-62dc-40ff-f0de-08d639d34055 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=[SATLEXCHOV01.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR12MB0742 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: Alexander.Deucher@amd.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Problem: A particular scheduler may become unsuable (underlying HW) after some event (e.g. GPU reset). If it's later chosen by the get free sched. policy a command will fail to be submitted. Fix: Add a driver specific callback to report the sched status so rq with bad sched can be avoided in favor of working one or none in which case job init will fail. v2: Switch from driver callback to flag in scheduler. v3: rebase v4: Remove ready paramter from drm_sched_init, set uncoditionally to true once init done. Signed-off-by: Andrey Grodzovsky --- drivers/gpu/drm/scheduler/sched_entity.c | 9 ++++++++- drivers/gpu/drm/scheduler/sched_main.c | 6 ++++++ drivers/gpu/drm/v3d/v3d_sched.c | 2 +- include/drm/gpu_scheduler.h | 3 +++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/scheduler/sched_entity.c b/drivers/gpu/drm/scheduler/sched_entity.c index 3e22a54..ba54c30 100644 --- a/drivers/gpu/drm/scheduler/sched_entity.c +++ b/drivers/gpu/drm/scheduler/sched_entity.c @@ -130,7 +130,14 @@ drm_sched_entity_get_free_sched(struct drm_sched_entity *entity) int i; for (i = 0; i < entity->num_rq_list; ++i) { - num_jobs = atomic_read(&entity->rq_list[i]->sched->num_jobs); + struct drm_gpu_scheduler *sched = entity->rq_list[i]->sched; + + if (!entity->rq_list[i]->sched->ready) { + DRM_WARN("sched%s is not ready, skipping", sched->name); + continue; + } + + num_jobs = atomic_read(&sched->num_jobs); if (num_jobs < min_jobs) { min_jobs = num_jobs; rq = entity->rq_list[i]; diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c index 63b997d..6b2fd49 100644 --- a/drivers/gpu/drm/scheduler/sched_main.c +++ b/drivers/gpu/drm/scheduler/sched_main.c @@ -420,6 +420,9 @@ int drm_sched_job_init(struct drm_sched_job *job, struct drm_gpu_scheduler *sched; drm_sched_entity_select_rq(entity); + if (!entity->rq) + return -ENOENT; + sched = entity->rq->sched; job->sched = sched; @@ -633,6 +636,7 @@ int drm_sched_init(struct drm_gpu_scheduler *sched, return PTR_ERR(sched->thread); } + sched->ready = true; return 0; } EXPORT_SYMBOL(drm_sched_init); @@ -648,5 +652,7 @@ void drm_sched_fini(struct drm_gpu_scheduler *sched) { if (sched->thread) kthread_stop(sched->thread); + + sched->ready = false; } EXPORT_SYMBOL(drm_sched_fini); diff --git a/drivers/gpu/drm/v3d/v3d_sched.c b/drivers/gpu/drm/v3d/v3d_sched.c index 80b641f..273d0fb 100644 --- a/drivers/gpu/drm/v3d/v3d_sched.c +++ b/drivers/gpu/drm/v3d/v3d_sched.c @@ -222,7 +222,7 @@ v3d_sched_init(struct v3d_dev *v3d) &v3d_sched_ops, hw_jobs_limit, job_hang_limit, msecs_to_jiffies(hang_limit_ms), - "v3d_render"); + "v3d_render", true); if (ret) { dev_err(v3d->dev, "Failed to create render scheduler: %d.", ret); diff --git a/include/drm/gpu_scheduler.h b/include/drm/gpu_scheduler.h index 0684dcd..4ae192a 100644 --- a/include/drm/gpu_scheduler.h +++ b/include/drm/gpu_scheduler.h @@ -264,6 +264,7 @@ struct drm_sched_backend_ops { * @hang_limit: once the hangs by a job crosses this limit then it is marked * guilty and it will be considered for scheduling further. * @num_jobs: the number of jobs in queue in the scheduler + * @ready: marks if the underlying HW is ready to work * * One scheduler is implemented for each hardware ring. */ @@ -283,12 +284,14 @@ struct drm_gpu_scheduler { spinlock_t job_list_lock; int hang_limit; atomic_t num_jobs; + bool ready; }; int drm_sched_init(struct drm_gpu_scheduler *sched, const struct drm_sched_backend_ops *ops, uint32_t hw_submission, unsigned hang_limit, long timeout, const char *name); + void drm_sched_fini(struct drm_gpu_scheduler *sched); int drm_sched_job_init(struct drm_sched_job *job, struct drm_sched_entity *entity,