From patchwork Wed May 30 19:54:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Grodzovsky X-Patchwork-Id: 10439941 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 78FC0601E9 for ; Wed, 30 May 2018 21:27:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6AAA828996 for ; Wed, 30 May 2018 21:27:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5C8D1295F6; Wed, 30 May 2018 21:27:16 +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 E1FAE28996 for ; Wed, 30 May 2018 21:27:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6F8D96E594; Wed, 30 May 2018 19:55:12 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM03-BY2-obe.outbound.protection.outlook.com (mail-by2nam03on0086.outbound.protection.outlook.com [104.47.42.86]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5BBF76E594; Wed, 30 May 2018 19:55:11 +0000 (UTC) Received: from SN1PR12CA0008.namprd12.prod.outlook.com (2a01:111:e400:5174::18) by DM2PR12MB0332.namprd12.prod.outlook.com (2a01:111:e400:50d0::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.797.11; Wed, 30 May 2018 19:55:09 +0000 Received: from DM3NAM03FT020.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e49::209) by SN1PR12CA0008.outlook.office365.com (2a01:111:e400:5174::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.820.11 via Frontend Transport; Wed, 30 May 2018 19:55:08 +0000 Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from SATLEXCHOV02.amd.com (165.204.84.17) by DM3NAM03FT020.mail.protection.outlook.com (10.152.82.193) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.20.820.8 via Frontend Transport; Wed, 30 May 2018 19:55:08 +0000 Received: from agrodzovsky-All-Series.amd.com (10.34.1.3) by SATLEXCHOV02.amd.com (10.181.40.72) with Microsoft SMTP Server id 14.3.382.0; Wed, 30 May 2018 14:55:06 -0500 From: Andrey Grodzovsky To: , Subject: [PATCH 2/2] drm/amdgpu: move amdgpu_ctx_mgr_entity_fini to f_ops flush hook. Date: Wed, 30 May 2018 15:54:18 -0400 Message-ID: <1527710058-11896-2-git-send-email-andrey.grodzovsky@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1527710058-11896-1-git-send-email-andrey.grodzovsky@amd.com> References: <1527710058-11896-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)(396003)(39380400002)(346002)(39860400002)(376002)(2980300002)(428003)(199004)(189003)(186003)(47776003)(450100002)(68736007)(316002)(4326008)(105586002)(50226002)(36756003)(5660300001)(53936002)(16586007)(426003)(2616005)(72206003)(53416004)(11346002)(54906003)(81156014)(81166006)(59450400001)(126002)(446003)(110136005)(86362001)(50466002)(2906002)(106466001)(305945005)(97736004)(575784001)(8676002)(6666003)(356003)(7696005)(26005)(77096007)(51416003)(76176011)(104016004)(478600001)(44832011)(476003)(48376002)(486006)(8936002)(336012); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR12MB0332; H:SATLEXCHOV02.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoDomainNonexistent; A:1; MX:1; X-Microsoft-Exchange-Diagnostics: 1; DM3NAM03FT020; 1:W++LT8RXIQe2Me5dXlKyGTovXB1yhLTqO5FKgcORKDLJehUHLZGSSJottOJZbsUyCzabq1hbhucGhlAdmoFc3kWZUenFxUxibyO+8YmdrIlIN2aj30q6mvg36SHARuK/ X-MS-PublicTrafficType: Email X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060); SRVR:DM2PR12MB0332; X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0332; 3:h2f9WLSJ0XXscdafFPGbEYCz057vHDCEIAeeEr/kgN+o2J0e6LIc5rk62PnMco28BZ3eCe8iYQbIq+a7/z/92P6v2Qy38K+f72qvtlTr0t0W1hVwNvirlm7e4ZuszDq50lidw1p2qSeK4zniXiE5bMAMPTeBr4LhtAUpDJH/HJ/ja9q10hjP0OSdx0Vc+nwTZKa8eQciV/LkQVuj0HhIedhg1G7yddlht9gvsron7KsggLydRMR+AwkL8HupDC9qW7FbrzHSOkiupHatXTIOFkMrlJxJJF396UEsIX3DNiObaxS1p1kBKwuSE1EUXQDcJK5LgpWqxOjWYsQgiT9NLJ+PG56AD4z/EUy1E8wg5Ec=; 25:EHI2lP0XknYfyfPdwWB4QegZep0Hfg/yj4EWIgdMpaogl93o2FGwQCyXyIDuB+2NF6DVUq/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pPuB+CcQEDpTY/35ncvoOG1o 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)(3002001)(3231254)(944501410)(52105095)(93006095)(93003095)(10201501046)(6055026)(149027)(150027)(6041310)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123562045)(6072148)(201708071742011)(7699016); SRVR:DM2PR12MB0332; BCL:0; PCL:0; RULEID:; SRVR:DM2PR12MB0332; X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0332; 4:d/H/hL6ihheIAw0wKkhnV3DrZjZpOXU5qc+9Uug6VadpFqE9slqkb3YSbBiNEuMX7aC8O7TE5Xl7isU556WIgeVkFqwLIjw2DVho9loadQDEoQ3hpAZWyHD/c0Ww5Gb/ubKK4wGAU8zV3D+dlU0TlmG3r0wEEMQbkViZ4nle1aqSixnucwUxG1DbXwnPJ3adn2QZRy506HTfZ5364k0hjZTevAlQqV1uoFEcPICfXGx1vSOLAbZ0J8qPIBrYLLfUOQ0vQoyA3NSSz+HxjHWM3IycZEKokvZSeEa6xuU/49Eg5UkgziAXlBKhmm+J5LRn X-Forefront-PRVS: 0688BF9B46 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM2PR12MB0332; 23:5WXTTY3EvE6n3zl4835RwHtg22DmRy+G3B8Zsmx37?= =?us-ascii?Q?yjJJoE31UB0AQ4lkLlcaI3W14wIwQ3sxRuNiVjUg3wSA3iiEBI2/JIUcjCdd?= =?us-ascii?Q?dI+H+9jhG2XLiJmCg53I/KqjbeXsLtjcdba7BQlC7dWDy/1hqQGQSfOXJ7mj?= =?us-ascii?Q?L3BLVSF3215u8xypJAnJcu+8Cw5OW168BPbsO1G2c6tKjA/L1FIT7ZWz0GaL?= =?us-ascii?Q?oYkq/w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ObIP0xyCT3p+dmpo1OL7nzEzT0aGVbCMuj86Y=; 24:95A6gy3UyVVax2IczTNgpW61cZj00VgrmAQeHMnDSQer68r5AjdMCpg7s+owJ1CS+F9o3D7KhO57ztoQnR2AUFWcekw3nLou6aPb0gcnDZs= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0332; 7:R0Xc1cXLJvGQt6yVq4tk/b13FjNS3T6lMpGUg1xesgzSzYoo5rcrpx5oOFPV8Dl8Wj1xK+6DNS8ZM8tAJxIF1Y2a3qC8OzJci+HFJeMcwCsfDEJAVrnSAF4Jst8hvlp02sZuwo/r9j5zbJ/7Tti+Icl6752ib6J6/EG90jcbOSYMQR3XRb07l++c4+HxpDSjzGZ8GzpHHNwn/9FBVuAWVoA3TvlKNmfWimsKN1ToIJUT8hP0GeOuCc7fLgikC7AL; 20:2Nif1XkgXpxVpbm9zuQ9YL/4mjUAJ4TYvJ5VjuMpeoQl3xhoIGQsLfiVu1QJ8o5xRP9k+cltCPEvHLJM7QvYcapmeQ1CWt0QrQetR4hMKxCyG2c9w/+iuTDcfpiR0pEA3BkibUDLTdMPmmoB5aCJIx5cFaanEVFxbMeeGNkZiYwyF1ZGtdEsSujQGa8uHSDONeAM/kIRbj59eJYI5NUMAtEvU+LnLoJ9H8fCeppSlBXkYZ6O0Wh7jYx3F+fSG2Ou X-MS-Office365-Filtering-Correlation-Id: 69e5a9ca-488b-4ca0-10bc-08d5c6673ee2 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 May 2018 19:55:08.0008 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 69e5a9ca-488b-4ca0-10bc-08d5c6673ee2 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=[SATLEXCHOV02.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR12MB0332 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 With this we can now terminate jobs enqueue into SW queue the moment the task is being killed instead of waiting for last user of drm file to release it. Also stop checking for kref_read(&ctx->refcount) == 1 when calling drm_sched_entity_do_release since other task might still hold a reference to this entity but we don't care since KILL means terminate job submission regardless of what other tasks are doing. Signed-off-by: Andrey Grodzovsky --- drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 13 +++++++------ drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 12 ++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 1 - 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c index c5bb362..db69045 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c @@ -452,23 +452,24 @@ void amdgpu_ctx_mgr_entity_fini(struct amdgpu_ctx_mgr *mgr) idp = &mgr->ctx_handles; + mutex_lock(&mgr->lock); idr_for_each_entry(idp, ctx, id) { - if (!ctx->adev) + if (!ctx->adev) { + mutex_unlock(&mgr->lock); return; + } for (i = 0; i < ctx->adev->num_rings; i++) { if (ctx->adev->rings[i] == &ctx->adev->gfx.kiq.ring) continue; - if (kref_read(&ctx->refcount) == 1) - drm_sched_entity_do_release(&ctx->adev->rings[i]->sched, - &ctx->rings[i].entity); - else - DRM_ERROR("ctx %p is still alive\n", ctx); + drm_sched_entity_do_release(&ctx->adev->rings[i]->sched, + &ctx->rings[i].entity); } } + mutex_unlock(&mgr->lock); } void amdgpu_ctx_mgr_entity_cleanup(struct amdgpu_ctx_mgr *mgr) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c index b0bf2f2..36a9acf 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c @@ -855,9 +855,21 @@ static const struct dev_pm_ops amdgpu_pm_ops = { .runtime_idle = amdgpu_pmops_runtime_idle, }; +static int amdgpu_flush(struct file *f, fl_owner_t id) +{ + struct drm_file *file_priv = f->private_data; + struct amdgpu_fpriv *fpriv = file_priv->driver_priv; + + amdgpu_ctx_mgr_entity_fini(&fpriv->ctx_mgr); + + return 0; +} + + static const struct file_operations amdgpu_driver_kms_fops = { .owner = THIS_MODULE, .open = drm_open, + .flush = amdgpu_flush, .release = drm_release, .unlocked_ioctl = amdgpu_drm_ioctl, .mmap = amdgpu_mmap, diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c index ca21549..1239384 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c @@ -930,7 +930,6 @@ void amdgpu_driver_postclose_kms(struct drm_device *dev, return; pm_runtime_get_sync(dev->dev); - amdgpu_ctx_mgr_entity_fini(&fpriv->ctx_mgr); if (adev->asic_type != CHIP_RAVEN) { amdgpu_uvd_free_handles(adev, file_priv);