From patchwork Mon Jun 4 18:39:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrey Grodzovsky X-Patchwork-Id: 10447153 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8E8A0601A1 for ; Mon, 4 Jun 2018 18:40:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7D17029045 for ; Mon, 4 Jun 2018 18:40:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 775DD2911D; Mon, 4 Jun 2018 18:40:31 +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 4B67B29045 for ; Mon, 4 Jun 2018 18:40:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E83566EBBF; Mon, 4 Jun 2018 18:40:12 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on0071.outbound.protection.outlook.com [104.47.34.71]) by gabe.freedesktop.org (Postfix) with ESMTPS id 833046EBC3; Mon, 4 Jun 2018 18:40:10 +0000 (UTC) Received: from SN1PR12CA0030.namprd12.prod.outlook.com (2a01:111:e400:5174::40) by BL0PR12MB2418.namprd12.prod.outlook.com (2603:10b6:207:4d::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.820.11; Mon, 4 Jun 2018 18:40:08 +0000 Received: from DM3NAM03FT014.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e49::208) by SN1PR12CA0030.outlook.office365.com (2a01:111:e400:5174::40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.820.11 via Frontend Transport; Mon, 4 Jun 2018 18:40:08 +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 DM3NAM03FT014.mail.protection.outlook.com (10.152.82.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.841.10 via Frontend Transport; Mon, 4 Jun 2018 18:40:08 +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.382.0; Mon, 4 Jun 2018 13:40:06 -0500 From: Andrey Grodzovsky To: , Subject: [PATCH v4 1/2] drm/scheduler: Avoid using wait_event_killable for dying process. Date: Mon, 4 Jun 2018 14:39:58 -0400 Message-ID: <1528137599-2188-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)(39860400002)(396003)(39380400002)(2980300002)(428003)(189003)(199004)(47776003)(26005)(356003)(305945005)(8936002)(59450400001)(4326008)(50226002)(8676002)(81166006)(81156014)(450100002)(126002)(478600001)(72206003)(426003)(2616005)(336012)(476003)(77096007)(44832011)(186003)(486006)(50466002)(68736007)(6666003)(110136005)(54906003)(53936002)(104016004)(53416004)(105586002)(2906002)(48376002)(16586007)(36756003)(97736004)(86362001)(51416003)(316002)(7696005)(106466001)(5660300001); DIR:OUT; SFP:1101; SCL:1; SRVR:BL0PR12MB2418; H:SATLEXCHOV01.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoDomainNonexistent; MX:1; A:1; X-Microsoft-Exchange-Diagnostics: 1; DM3NAM03FT014; 1:dO4rtSXbpwnuVNXbXxe70e/1FU0qM/OcgQQS4TTfGw7cQub3R5MC9JmYeZYzQYhvkJ9Si73WppOSx8zL9A8ZcWrSAZ/OKMFN1JaKgzc3p8JxkiRTW4/XLbn+Z+QBSBGa X-MS-PublicTrafficType: Email X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060); SRVR:BL0PR12MB2418; X-Microsoft-Exchange-Diagnostics: 1; BL0PR12MB2418; 3:PWCT8Z8LT1T0jNcLPCC3RPo67kqJb6hTJoUKQx9bz1qQC2F3NohXxlLdajUwk5EHskldcWMXjwI/yzyL3gwh25ikL37GjY7tJogCL1CwXmnCtayfDQJkAYPjIiT6pyOAYvaXjMzGmFtl6oeHexkUaXj5GgCJN43PIvxOuJAqqjE9bNQ/6Wja3dSFciG7xK94RebKAxffpb7DKHdC9EOJ3w36/UHhDtsnDebr14QZspgRlU9563QO10XnLcAPEMhDDLOkvy5bNqRb+Z57q24B2Cm/GWDLnGCKZnOT71c4fosK9u9aUsI52Ki3bo74TJL7iuPDwp3HaFf1cfJMcnWYreWcRu+M41GVMK5RByXzQ7M=; 25:AHq9JkDpyZSM4RjIU0ACASO73vR7xbESwBV9NABWxF0CFVOlD3MyZ//sKLt/DHXofIV4n4e60nLSb1B/5JMRnINLYI6rMPtruRbJTLDMNdlUo5xE1fBza4/PcJAmYRiDDY+uLE24geWuszPb9hpvGa/bLB+HQiVfKdIITamNOKiOVh0tnx94FGDIfrmip8+fjPKjUHz57DtxGHlio9O6cwVYlNbL9U75BFC9Po5LMUCPqykd4wEi/ZX3yYjJ8Zv37p/l949tCiWVSOZwg/OIPSgZPYdd1V+Z93oN70+CK3V2C12I9+dl4yEqyMtNl+jAVpIatIOsdgffyWqvMEcoIA== X-MS-TrafficTypeDiagnostic: BL0PR12MB2418: X-Microsoft-Exchange-Diagnostics: 1; BL0PR12MB2418; 31:XhSCAxYAfrKEoyqW3xjANSXQpJ8/3pgY4nOB6NMjCQ4T3W19gvfuvC9U8EMB0Y9vq7S2iz1O6kv2I7jBbUuguOWvszWrl0PXKGTkZtCy1LTNmcKbaaqPaB7m4YjJ9YTL+Tcj3oFQWhSKI3OQXFpXb/5onvIVvNARpINvynUqAoA+wgXdC0i24mfmSL+/CeMgX3Zvm+6qsIKjVAjUBguAjlrfSwyL5VJM78Z1GezgxaA=; 20:0rUvE1qT2d1ecL0CwRPNPOywQHopXycAJB1HUb7Hhpkiv8jOGeR3z7vT8cGot9umjb84SfMFOSMisvdAoz8qhT6cuT5jLJt0jBKG1tmPrpRBzzaUnewAT43CHQF5JDuJdXUEP+zzbeJPjxWg3cKL4EK3Ek+BDpAS/sbSHw/slZVtGXxxHpYb5VQSbbobIo+qiZ0FzYhelQYmuT8kpuzcFtVL5erkh2AqgtI6qQAOlpgp6EnJ2pLjjICq12I117zMGicdGMUoadRRxek4uqEG1blMT+CeuB+UuAg702m6n/NPvywb/Etp2AnedCrr8LnqRhvEgjjW77BlPML0IhGHidTZsMyxBIgq31iFk0yE3O/lXe8XkSPRkUzbe3vJ3BRnFB/g39F3sqKTpeYSRX2R1WcWCkCw6h9LV6RWAKWLch4SOgABeFMqUODdYv+QUxsSRNLxystLLb2COOZL9ott5GISzAzCGMD9na8LQapChFcSFkDXw+6S3rK2P16NefEA 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)(3231254)(944501410)(52105095)(10201501046)(93006095)(93003095)(3002001)(6055026)(149027)(150027)(6041310)(20161123562045)(20161123560045)(20161123564045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016); SRVR:BL0PR12MB2418; BCL:0; PCL:0; RULEID:; SRVR:BL0PR12MB2418; X-Microsoft-Exchange-Diagnostics: 1; BL0PR12MB2418; 4:9YLc9qPx4MhOJljqVCZONbqF3KFlukDIdua+44DdY9PcEiB3Xw/dlQQbnJ2QuFLp3ZSh1BYEBgHmhidePXrBY79P98q258Hbo/OHCX4FYlYAvEKEZ8/t071YsJwyNj9Oxtj7xDoDYrfKN0qe9L3Aiy4sWIPChvYJEowUi0YHbtuygUgxz46u0Jso9kIp1dbUr8oGCNjIaQqlfq/PhiWAeeHCsCjwq7D3fyPJcTbHByOX2GviMmTFJx+NqcamAwp9D2PiSGLjGCUREBkYdaEKPC4VqqDr4YMacliuYzuNuoziHLJ+bMC2Nj6X27BaA92Z X-Forefront-PRVS: 069373DFB6 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BL0PR12MB2418; 23:O9QUQb88vBKFe7qBP9q1AwGdx4yLb6aGtR3q+f7y1?= =?us-ascii?Q?dAFou02Ze3z8cwjPoxR9v+B86nHQ4Xbg8wZrBU/ObRpT3fkBEeo+FZqX4Wu/?= =?us-ascii?Q?ApVVRRJUDHhnRn6nCEKVCUUDOO4Ioce3r8UKzZ4DVAlvWqJsjIjTu6iY33Zj?= =?us-ascii?Q?AhZqibs1GM0nlD5YGW6j1IysnL8akgRFgFnUBpX7jQ25zg2RDutjD+6VKIcI?= =?us-ascii?Q?bhYMLJ7X4nVl1oHb3VYPsDEW1dyvZqSs6Oup9y7zul5lcZrTbij7xDZC9Cfy?= =?us-ascii?Q?6p5C91rAm7BtqUfVEIPRImmaetwlmp6bZyzHknytmfS4rn8tXIMeN3Qb5RrY?= =?us-ascii?Q?rKFtWCLnL2XllHlW7NNpkBtUSyjFMQ01O+PPBNb/6yb3xQxsGA9PpK3G2trV?= =?us-ascii?Q?wFoRJzTq6gRxFIS6D3XMsneD5hP8Xnn9rGCx06HZYDPnPV0vo03lBzmmQo1J?= =?us-ascii?Q?cOeKUk46Ia7dw2Ap5Kc1tPXocsDlMoQC/4iHAeEdn04dUve5wBRn4gM/ASel?= =?us-ascii?Q?Y1E5Nv+fGBFwwgmC1Sc2CGq8ut4h8Dj7KraLSqnopLNCZ1kYVT8pwV1cyuqk?= =?us-ascii?Q?FW1H0FNRJy0fxaynPrZtQWepZb6FyXOg0erEitancGC7MxhVoYlIz3OS9O6b?= =?us-ascii?Q?mF1GhpeVpgqgxiYdASYae3SsL6z7r0GAGIdgAxne9BifM8y25leX8/iJEawC?= =?us-ascii?Q?NCOgu/KjPUveTSbXulQ0ZyRVaEUusOqJGRYEwm8IkyOiqqXubZKxwqZwg4Hi?= =?us-ascii?Q?etXvvp7cXI+YDBR4NNDchihGNJm0lgeAxdB5GUE0P95aLVNfr+0XWmDOrAjX?= =?us-ascii?Q?mYr1s/IAqSN5TOBPEq/BKpLizMXPF1nkZiaDJv28DZSxe728K7HqfZwXvGhW?= =?us-ascii?Q?KOUxKrq3FZNyVrrmpUBez4ARXosZv/e24j4WbD8Tl6nPwSjxITGdi6zMdIl0?= =?us-ascii?Q?UTn1aM3yrSKZcv6QjyHBBdQ1c7jobBsoP7f0kWFhQVkrsv8ph/nljTo1Zxzr?= =?us-ascii?Q?NFMKaLxMmCFuYjkwialSF74ve5ZgByehQxEBF4dGAYrvZVe1ucMrTKcQuJLd?= =?us-ascii?Q?hurALPCbkBz56XCssmxGtuqica9Md7tnTur80RfEe9/xOJRg3sL+r6htDJUg?= =?us-ascii?Q?uCBcu4bdBLxsvLnwcydzlnIoPnhlQvwDZlHYuaA8dkAx1woI7hIzDR0bCWFO?= =?us-ascii?Q?qcazhImld0Yefs=3D?= X-Microsoft-Antispam-Message-Info: NwD2TjSW6+5D2zsppwaNr98EE5q/Yf7Dis7dld6KbGCvMeS3PufCq7+4R63I5CS89ucS1TArKmM1XUanlRNu4rVWkXVv3uGGLaceK+WnpjXiNY2mjnIby93W/w1KDRmwLRy3y//9MRZxVFh98p38plfl6Ua1WtC8z8clcPfq1Gx3M47CS4ajuudZKhIZUcac X-Microsoft-Exchange-Diagnostics: 1; BL0PR12MB2418; 6:xFvxwydA8OH272wy77aUYtklkfglMTqOzm2hXzYCqsUQatY+s1d5UwnE51TbGuDjADp5/LO3uoSOhMDVCPCrhKpSiY1WluU5wTF4jC++6xYfnD9ka5gSn781CcFnDjRaGalfpFVDs/3UkuxRLlMSXX6sjND0GH0uJsxNxWT3SS+9u4ETr93hKJE69oFDO1ODDrgQTkrGpaX0e8QJykKYQR8gXSdyIGDKkg91XdAkM7bf8z5P0XpM6/BBI2mucBzjpZU4WrrPgtUzKxePDRBn+5t1jFhpGTISwan2D8B1TH2uXpxrz+1ovdbPyu4e0YmzCFrLvsz7fKsJq95FBDJQVYIDBOhpcmLDaAbe7NHehpd9E6jvJQKtt7kOMDyzrHPRzcuFgGU0alxp3EK1vWd92iWTJh6cYjCHHxrPmW/AJWLvURMZvF+amVdqBeBLdKU83g994JjbpohUu7b0DHsJEQ==; 5:6RgQmcYC9Vj3swWr7E57MNxV/S0QQz6PgIFXRJbYIhcT/YBogXnQQCQo2pfLdhsLThWnoouwDq+M7/8QZ+/weRxthzLva5wq+4I7fhJ026oAj7Y4yVfnyepKDve8vL+dsixpdOcR5VzlIQZg6HIER6pbc6XFlUJFQ5NpqBU1LxQ=; 24:RD+gbAHfhlhowuiPNsWPNzJDBVWDVXTOrZRFfH9bowh9XAj7sFkwtdL0iAt09hRMmks3rnh2ayQWHFcxcPXZl6DqQaHY0IwtnJlcgFhdyMI= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BL0PR12MB2418; 7:TGaUm0R90yr8di+97kPEkfGEStwecpc8Ze60bPg6cj6jPu+so9BtKaNFZKGr+WsrsYDN3LuZITFNCcaX7mRoiFvKVde0Kch91nKw3q7gRccj1nlgCUByc3nz41YltVEPPizRf3DhK+6srnJARhQ5DLeMevCdmijdLLfIeItUlAdV/tz0Cy2UWNQFBi4ixdj/BEnhjX1IhNUB6uqW5gBzMpi7bjKliU7NB0rwuf7ktzTmGphV0Sj8sJ7TXpazzoM1; 20:bI2xSWAOlQ+Q4tHx0rDbj1cuYM1c2c+s3R8qefMYiXtJ4Y55mk6xPEhw7zDOPk2vaz1Z2BjFK6MUbwtMexxinA58CriX57uBn7wpNJKOho0Q86Fg2JY1ddyLBeJtfZtBBXnJJjefFEIy5fsHYvI+DUoLM5blBw7QxR6ttaLp7GnnXvwGDLEG5mnjqnlsKjNYdnS6WurP0uhj13+B328ZAU1mbwQh0DNdBpZ3Ar6qWOAFqujSDDIZP+gRPa4FBlwX X-MS-Office365-Filtering-Correlation-Id: 02197504-3b4b-4642-3611-08d5ca4a98dd X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jun 2018 18:40:08.2099 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 02197504-3b4b-4642-3611-08d5ca4a98dd 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: BL0PR12MB2418 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: Christian.Koenig@amd.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Dying process might be blocked from receiving any more signals so avoid using it. Also retire enity->fini_status and just check the SW queue, if it's not empty do the fallback cleanup. Also handle entity->last_scheduled == NULL use case which happens when HW ring is already hangged whem a new entity tried to enqeue jobs. v2: Return the remaining timeout and use that as parameter for the next call. This way when we need to cleanup multiple queues we don't wait for the entire TO period for each queue but rather in total. Styling comments. Rebase. v3: Update types from unsigned to long. Work with jiffies instead of ms. Return 0 when TO expires. Rebase. v4: Remove unnecessary timeout calculation. Signed-off-by: Andrey Grodzovsky Reviewed-by: Christian König for the whole --- drivers/gpu/drm/scheduler/gpu_scheduler.c | 67 ++++++++++++++++++++++--------- include/drm/gpu_scheduler.h | 7 ++-- 2 files changed, 53 insertions(+), 21 deletions(-) diff --git a/drivers/gpu/drm/scheduler/gpu_scheduler.c b/drivers/gpu/drm/scheduler/gpu_scheduler.c index 8c1e80c..6a31670 100644 --- a/drivers/gpu/drm/scheduler/gpu_scheduler.c +++ b/drivers/gpu/drm/scheduler/gpu_scheduler.c @@ -181,7 +181,6 @@ int drm_sched_entity_init(struct drm_gpu_scheduler *sched, entity->rq = rq; entity->sched = sched; entity->guilty = guilty; - entity->fini_status = 0; entity->last_scheduled = NULL; spin_lock_init(&entity->rq_lock); @@ -219,7 +218,8 @@ static bool drm_sched_entity_is_initialized(struct drm_gpu_scheduler *sched, static bool drm_sched_entity_is_idle(struct drm_sched_entity *entity) { rmb(); - if (spsc_queue_peek(&entity->job_queue) == NULL) + + if (!entity->rq || spsc_queue_peek(&entity->job_queue) == NULL) return true; return false; @@ -260,25 +260,39 @@ static void drm_sched_entity_kill_jobs_cb(struct dma_fence *f, * * @sched: scheduler instance * @entity: scheduler entity + * @timeout: time to wait in for Q to become empty in jiffies. * * Splitting drm_sched_entity_fini() into two functions, The first one does the waiting, * removes the entity from the runqueue and returns an error when the process was killed. + * + * Returns the remaining time in jiffies left from the input timeout */ -void drm_sched_entity_do_release(struct drm_gpu_scheduler *sched, - struct drm_sched_entity *entity) +long drm_sched_entity_do_release(struct drm_gpu_scheduler *sched, + struct drm_sched_entity *entity, long timeout) { + long ret = timeout; + if (!drm_sched_entity_is_initialized(sched, entity)) - return; + return ret; /** * The client will not queue more IBs during this fini, consume existing * queued IBs or discard them on SIGKILL */ - if ((current->flags & PF_SIGNALED) && current->exit_code == SIGKILL) - entity->fini_status = -ERESTARTSYS; - else - entity->fini_status = wait_event_killable(sched->job_scheduled, - drm_sched_entity_is_idle(entity)); - drm_sched_entity_set_rq(entity, NULL); + if (current->flags & PF_EXITING) { + if (timeout) + ret = wait_event_timeout( + sched->job_scheduled, + drm_sched_entity_is_idle(entity), + timeout); + } else + wait_event_killable(sched->job_scheduled, drm_sched_entity_is_idle(entity)); + + + /* For killed process disable any more IBs enqueue right now */ + if ((current->flags & PF_EXITING) && (current->exit_code == SIGKILL)) + drm_sched_entity_set_rq(entity, NULL); + + return ret; } EXPORT_SYMBOL(drm_sched_entity_do_release); @@ -290,11 +304,18 @@ EXPORT_SYMBOL(drm_sched_entity_do_release); * * This should be called after @drm_sched_entity_do_release. It goes over the * entity and signals all jobs with an error code if the process was killed. + * */ void drm_sched_entity_cleanup(struct drm_gpu_scheduler *sched, struct drm_sched_entity *entity) { - if (entity->fini_status) { + + drm_sched_entity_set_rq(entity, NULL); + + /* Consumption of existing IBs wasn't completed. Forcefully + * remove them here. + */ + if (spsc_queue_peek(&entity->job_queue)) { struct drm_sched_job *job; int r; @@ -314,12 +335,22 @@ void drm_sched_entity_cleanup(struct drm_gpu_scheduler *sched, struct drm_sched_fence *s_fence = job->s_fence; drm_sched_fence_scheduled(s_fence); dma_fence_set_error(&s_fence->finished, -ESRCH); - r = dma_fence_add_callback(entity->last_scheduled, &job->finish_cb, - drm_sched_entity_kill_jobs_cb); - if (r == -ENOENT) + + /* + * When pipe is hanged by older entity, new entity might + * not even have chance to submit it's first job to HW + * and so entity->last_scheduled will remain NULL + */ + if (!entity->last_scheduled) { drm_sched_entity_kill_jobs_cb(NULL, &job->finish_cb); - else if (r) - DRM_ERROR("fence add callback failed (%d)\n", r); + } else { + r = dma_fence_add_callback(entity->last_scheduled, &job->finish_cb, + drm_sched_entity_kill_jobs_cb); + if (r == -ENOENT) + drm_sched_entity_kill_jobs_cb(NULL, &job->finish_cb); + else if (r) + DRM_ERROR("fence add callback failed (%d)\n", r); + } } } @@ -339,7 +370,7 @@ EXPORT_SYMBOL(drm_sched_entity_cleanup); void drm_sched_entity_fini(struct drm_gpu_scheduler *sched, struct drm_sched_entity *entity) { - drm_sched_entity_do_release(sched, entity); + drm_sched_entity_do_release(sched, entity, MAX_WAIT_SCHED_ENTITY_Q_EMPTY); drm_sched_entity_cleanup(sched, entity); } EXPORT_SYMBOL(drm_sched_entity_fini); diff --git a/include/drm/gpu_scheduler.h b/include/drm/gpu_scheduler.h index 496442f..7c2dfd6 100644 --- a/include/drm/gpu_scheduler.h +++ b/include/drm/gpu_scheduler.h @@ -27,6 +27,8 @@ #include #include +#define MAX_WAIT_SCHED_ENTITY_Q_EMPTY msecs_to_jiffies(1000) + struct drm_gpu_scheduler; struct drm_sched_rq; @@ -84,7 +86,6 @@ struct drm_sched_entity { struct dma_fence *dependency; struct dma_fence_cb cb; atomic_t *guilty; - int fini_status; struct dma_fence *last_scheduled; }; @@ -283,8 +284,8 @@ int drm_sched_entity_init(struct drm_gpu_scheduler *sched, struct drm_sched_entity *entity, struct drm_sched_rq *rq, atomic_t *guilty); -void drm_sched_entity_do_release(struct drm_gpu_scheduler *sched, - struct drm_sched_entity *entity); +long drm_sched_entity_do_release(struct drm_gpu_scheduler *sched, + struct drm_sched_entity *entity, long timeout); void drm_sched_entity_cleanup(struct drm_gpu_scheduler *sched, struct drm_sched_entity *entity); void drm_sched_entity_fini(struct drm_gpu_scheduler *sched,