From patchwork Wed May 16 15:33:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrey Grodzovsky X-Patchwork-Id: 10404231 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 70B60601F7 for ; Wed, 16 May 2018 15:33:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5E13B28455 for ; Wed, 16 May 2018 15:33:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5060B28501; Wed, 16 May 2018 15:33:32 +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.1 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED, T_DKIM_INVALID 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 2524C28455 for ; Wed, 16 May 2018 15:33:30 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A085C6E45D; Wed, 16 May 2018 15:33:29 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on0040.outbound.protection.outlook.com [104.47.33.40]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0DEED6E45D; Wed, 16 May 2018 15:33:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=EmGLWeBbGYXAUwejy7eB+n3henFI0VrWGFMW8KRur08=; b=IPHbeSLt6hQN4cypyHmOFSvMSlOmCeLryG33ggzE3+YSAmwpJWD6gJFEKXaghr3tDtaSjAPCyGcsnMFtI+T/zSrIGNluqKbCsximglT/pNAoaV4d8TbUsYOfCbhOU0JSNsJgK21knFvZO5QltsicPUuy7+a8ZHpIKzOK7SyBe+Q= Received: from BN6PR12CA0037.namprd12.prod.outlook.com (2603:10b6:405:70::23) by DM2PR12MB0331.namprd12.prod.outlook.com (2a01:111:e400:50d0::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.755.16; Wed, 16 May 2018 15:33:25 +0000 Received: from DM3NAM03FT031.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e49::201) by BN6PR12CA0037.outlook.office365.com (2603:10b6:405:70::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.776.11 via Frontend Transport; Wed, 16 May 2018 15:33:25 +0000 Authentication-Results: spf=none (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; pengutronix.de; dkim=none (message not signed) header.d=none;pengutronix.de; dmarc=permerror action=none header.from=amd.com; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from SATLEXCHOV01.amd.com (165.204.84.17) by DM3NAM03FT031.mail.protection.outlook.com (10.152.82.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.20.755.15 via Frontend Transport; Wed, 16 May 2018 15:33:24 +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; Wed, 16 May 2018 10:33:23 -0500 From: Andrey Grodzovsky To: , Subject: [PATCH v2] drm/scheduler: Remove obsolete spinlock. Date: Wed, 16 May 2018 11:33:13 -0400 Message-ID: <1526484793-14368-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)(396003)(39380400002)(346002)(376002)(39860400002)(2980300002)(428003)(189003)(199004)(126002)(476003)(97736004)(2616005)(356003)(426003)(50226002)(81156014)(86362001)(81166006)(44832011)(53416004)(486006)(48376002)(336012)(8936002)(59450400001)(51416003)(50466002)(105586002)(186003)(8676002)(26005)(77096007)(106466001)(110136005)(54906003)(305945005)(36756003)(7696005)(47776003)(16586007)(5660300001)(478600001)(72206003)(4326008)(2906002)(53936002)(104016004)(68736007)(6666003)(316002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR12MB0331; H:SATLEXCHOV01.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoDomainNonexistent; MX:1; A:1; X-Microsoft-Exchange-Diagnostics: 1; DM3NAM03FT031; 1:X9K9QNltsdiwc47/IYTgvAvejHMnvlndCrXAl5giMqoUbJwnWoLqO8YzRFhnDt/RotlcXdneXHoA2FIaSrof2HvkR7u48I4Iwi94nkYdE/grubT5jUUnEg85ik9HKQES X-MS-PublicTrafficType: Email X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060); SRVR:DM2PR12MB0331; X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0331; 3:S5XVhbiQmwt1Y02P8PkI/sZyao7xqkNTkXul1Bou4ioisXo0b8FG46eDKbLqrYBpipha5I1CeTfT+KRpuqomyyaCLBa02hcImXGpBJbpr0xqElZzh0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fNxWcyAugzC4K54nNXVtAqERNnryoUfYiv2FxDiV9gpG/GGGdtnu2ruXZBkomMCixjvVUTdGEXx0Kan5n3pn5l7S5F90NVG63QcuMybx/Bktg0hydawmQ9LhZtnmxLGRTnSyBxCrs8agNGsZxqN+C/8uy3V2j6u0EiBIx0GHUjzQ2urEbvZIxEKyBeRA/UtgNkKzKquMyl+CcXDsgEJEokGKuJu169VLmFaewDBcR4oG9uQOooP//AkkxYXvwQncfCH6zT9eTikKLts4vGXTPm+vnoc/Ga8Is8Ls8Nc0whY2CoQmDWEEdVbnHlmHMgExkrixqQzEGO6cPzm4EBZYnTSdk 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)(3002001)(93006095)(93003095)(10201501046)(6055026)(149027)(150027)(6041310)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123560045)(6072148)(201708071742011); SRVR:DM2PR12MB0331; BCL:0; PCL:0; RULEID:; SRVR:DM2PR12MB0331; X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0331; 4:Of0ihZP/KcKCyB7O9pjPY30QXRInBKbdZxssyAJgPJRPbMjjOV15ODkSRJq8Xv7q4JhyP5h14xI1PD5aNjpjB7OJrpe2R+7x69CkJTuf8neg8NfHQIUayeN48KUylr8ZvKRGXm4LBpMuqkxfMCmvH4lJcDWyGzkVCkTs2YnuNz3VSYlOpDL4M3HRhWzUdX/dtL0eQjVmTUJ3DDBhdifwc77rp9ImeOaRQXmgRlhABEEikNKwNCjcsCFmT0GU+jR0Am8Y+WgT5cp8rNUiMXZNdH5ZRzhilUytNXMpS8nuqVXGkzwxDq+9SRwdZFv74tzW X-Forefront-PRVS: 0674DC6DD3 X-Microsoft-Exchange-Diagnostics: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zoTUSQXq2TgBPMTh4T2DZPDogBqeA==; 5:vPqaZYsk4Mf0WIlishRbxexXddNaaNJnCz1/l0rhRJwZPGzSMM3vmZ0pijhSCLzJogqnJtfJTIxMFXITTuen833qA4cjKeOWl039h2xp0EPgtd0Iihpgrq5yE6GN/bdlkg0TMSsAtAXrWz4qD3KcSAsyqmcD9toEjnLF+YjtLBw=; 24:Ecu03uuMlsQD50rsvF1dU/0DuEzBInPiEAGjRjAC28s4e4kQXQdjXfa3AxvGVssWtMOi9Vohmp8lN2tEDnuol7/2XiM8v645pD8oqPf5IQI= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0331; 7:HiUvNDM+z5/XaT1X1m8XbVwHhElkbHdNGLQwFe5HpS5xXSpdsqmBamnYGTGeieoEJxbmIHctuMCBR0NMRnSH20k6dgJ6i63gDA6teZTfPKO/O6haGzoIY4/V78FujJFHvuNCXmkyoqH+VQJm14iQU4ULUA9uyRkoFpp1Wv7aCUmt6qu2Y7Cv97tNGKRtr3GsVs+NBKyIt74hmDBNAjApSUEne4hWuBD+e5hzLGHciSsiTONuP/g7tKfT8Kph0Ldq; 20:224sP3ZjsdbiQYsgrmXRysJblTLPf+Qj2d81Yln7JEpOrm+9d5vrJ3vYcu8abBANHsjs+eK5v3lWEtn95RxecNzy9dSxzrlwUipTMJ8itVI/CzMvj0ISUq+pxTOeNI0O06NuMfHjIowuc1nG3DkdCqJUbnaJfQELLoIgA2GUuA58hLs8ZMcjv2iQWWAJKeaBSpydVCUSgcNZ0uyFNHfqChXlwUbWsQyNv5vowSfyIe07WCX9MLaGn/vSE5dIqB66 X-MS-Office365-Filtering-Correlation-Id: f3000b2a-1d82-43f7-9c1b-08d5bb425d07 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 May 2018 15:33:24.3464 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f3000b2a-1d82-43f7-9c1b-08d5bb425d07 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: DM2PR12MB0331 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 This spinlock is superfluous, any call to drm_sched_entity_push_job should already be under a lock together with matching drm_sched_job_init to match the order of insertion into queue with job's fence seqence number. v2: Improve patch description. Add functions documentation describing the locking considerations Signed-off-by: Andrey Grodzovsky Reviewed-by: Christian König --- drivers/gpu/drm/scheduler/gpu_scheduler.c | 15 ++++++++++----- include/drm/gpu_scheduler.h | 1 - 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/scheduler/gpu_scheduler.c b/drivers/gpu/drm/scheduler/gpu_scheduler.c index 1f1dd70..80dd66c 100644 --- a/drivers/gpu/drm/scheduler/gpu_scheduler.c +++ b/drivers/gpu/drm/scheduler/gpu_scheduler.c @@ -140,7 +140,6 @@ int drm_sched_entity_init(struct drm_gpu_scheduler *sched, entity->last_scheduled = NULL; spin_lock_init(&entity->rq_lock); - spin_lock_init(&entity->queue_lock); spsc_queue_init(&entity->job_queue); atomic_set(&entity->fence_seq, 0); @@ -414,6 +413,10 @@ drm_sched_entity_pop_job(struct drm_sched_entity *entity) * * @sched_job The pointer to job required to submit * + * Note: To guarantee that the order of insertion to queue matches + * the job's fence sequence number this function should be + * called with drm_sched_job_init under common lock. + * * Returns 0 for success, negative error code otherwise. */ void drm_sched_entity_push_job(struct drm_sched_job *sched_job, @@ -424,11 +427,8 @@ void drm_sched_entity_push_job(struct drm_sched_job *sched_job, trace_drm_sched_job(sched_job, entity); - spin_lock(&entity->queue_lock); first = spsc_queue_push(&entity->job_queue, &sched_job->queue_node); - spin_unlock(&entity->queue_lock); - /* first job wakes up scheduler */ if (first) { /* Add the entity to the run queue */ @@ -594,7 +594,12 @@ void drm_sched_job_recovery(struct drm_gpu_scheduler *sched) } EXPORT_SYMBOL(drm_sched_job_recovery); -/* init a sched_job with basic field */ +/** + * Init a sched_job with basic field + * + * Note: Refer to drm_sched_entity_push_job documentation + * for locking considerations. + */ int drm_sched_job_init(struct drm_sched_job *job, struct drm_gpu_scheduler *sched, struct drm_sched_entity *entity, diff --git a/include/drm/gpu_scheduler.h b/include/drm/gpu_scheduler.h index 350a62c..683eb65 100644 --- a/include/drm/gpu_scheduler.h +++ b/include/drm/gpu_scheduler.h @@ -56,7 +56,6 @@ struct drm_sched_entity { spinlock_t rq_lock; struct drm_gpu_scheduler *sched; - spinlock_t queue_lock; struct spsc_queue job_queue; atomic_t fence_seq;