From patchwork Thu Oct 25 15:08:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chunming Zhou X-Patchwork-Id: 10655961 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 C62AA13B5 for ; Thu, 25 Oct 2018 15:08:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B37C52BAA2 for ; Thu, 25 Oct 2018 15:08:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A79D32BAA4; Thu, 25 Oct 2018 15:08:45 +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=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 02C492BAA2 for ; Thu, 25 Oct 2018 15:08:45 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BE25F6E298; Thu, 25 Oct 2018 15:08:43 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from NAM03-DM3-obe.outbound.protection.outlook.com (mail-dm3nam03on0040.outbound.protection.outlook.com [104.47.41.40]) by gabe.freedesktop.org (Postfix) with ESMTPS id D2F416E296; Thu, 25 Oct 2018 15:08:41 +0000 (UTC) Received: from DM3PR12CA0043.namprd12.prod.outlook.com (2603:10b6:0:56::11) by DM3PR12MB0745.namprd12.prod.outlook.com (2a01:111:e400:5984::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1250.30; Thu, 25 Oct 2018 15:08:39 +0000 Received: from BY2NAM03FT032.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e4a::206) by DM3PR12CA0043.outlook.office365.com (2603:10b6:0:56::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1273.19 via Frontend Transport; Thu, 25 Oct 2018 15:08:39 +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 BY2NAM03FT032.mail.protection.outlook.com (10.152.84.228) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1273.13 via Frontend Transport; Thu, 25 Oct 2018 15:08:39 +0000 Received: from zhoucm1.amd.com (10.34.1.3) by SATLEXCHOV01.amd.com (10.181.40.71) with Microsoft SMTP Server id 14.3.389.1; Thu, 25 Oct 2018 10:08:37 -0500 From: Chunming Zhou To: Date: Thu, 25 Oct 2018 23:08:31 +0800 Message-ID: <20181025150831.19318-1-david1.zhou@amd.com> X-Mailer: git-send-email 2.17.1 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)(979002)(396003)(346002)(376002)(136003)(39860400002)(2980300002)(428003)(189003)(199004)(6916009)(14444005)(2351001)(47776003)(2906002)(5660300001)(54906003)(1857600001)(1076002)(68736007)(86362001)(53936002)(186003)(105586002)(4326008)(478600001)(50466002)(26005)(106466001)(575784001)(126002)(50226002)(77096007)(8676002)(356004)(476003)(6346003)(6666004)(81166006)(53416004)(2616005)(72206003)(66574009)(8936002)(104016004)(81156014)(2870700001)(5820100001)(336012)(305945005)(486006)(36756003)(97736004)(7696005)(23676004)(426003)(316002)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM3PR12MB0745; H:SATLEXCHOV01.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoDomainNonexistent; MX:1; A:1; X-Microsoft-Exchange-Diagnostics: 1; BY2NAM03FT032; 1:2+IMl8zuL/VlrOs/APhrb2leVwUyaUJkgvMHO5NrPDDiflRd2gmpWzrH8wINrrsU9nKee21hlMGjVJs+pDMazYFsqPYad44RFJgR0JrdJmNPv6T+FDtZScspP8O3z79X X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7b660748-d3e2-4e58-faa7-08d63a8bbed0 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(5600074)(711020)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060); SRVR:DM3PR12MB0745; X-Microsoft-Exchange-Diagnostics: 1; DM3PR12MB0745; 3:rBhpzT7RqikVecmUzELT89kdEp+RvkZ4SU3NKhbKXySYnHd3dVeK9MuMwFO1uQhxcj3dPVXg2HgMR9Cbg6nreTDUkcq5wtGM1O/tjeYc1G5ichO75bvCWUv2QuFzj3KK/L4yTrPoHRZvt56swPORnzBT7CZNxTTyYfo5yOtAKU9dN8Q2HEwpoR0r84rxuj3BPkPKUURWohLApQ9e4NLSm5wEECM6flTeW8ZJgo9FJYTBN/Esyf35/aZ8kM3E67MahLD8VvVgoAoC2lFV2G4yHyTgUtc5bdAJ2EMuAMcYNIwsgg7yHBMSl8nFv+BDbwYqWxafk+UhwEebqJDuI+QurFB5Lf5PfR2d/ujdZBxEXj8=; 25:ScmR1iNEnNLcYpDzPT7USTa0uvJGCXEvILkQRnNxmXNvFTQ9d8O7wVufmpcHhsZAYI4gMDqxM2G8ZcCa/CP1U71bVWMKSEjYeiidpIjuTQvBvaDStklNJK8D3U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PRVS: X-Exchange-Antispam-Report-Test: UriScan:(17755550239193)(767451399110)(228905959029699)(217544274631240)(8415204561270); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93003095)(3002001)(3231355)(944501410)(52105095)(6055026)(148016)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(20161123558120)(20161123562045)(201708071742011)(7699051)(76991095); SRVR:DM3PR12MB0745; BCL:0; PCL:0; RULEID:; SRVR:DM3PR12MB0745; X-Microsoft-Exchange-Diagnostics: 1; DM3PR12MB0745; 4:KuGljkBn4/95abpgfd5V5a8k/I5fnpLSBY4ZqVYVmkK1vTx+Zh5yBqTe1jW6BxGNPnzRyozl/tbnS8S6Uj/PaIvwisAqjb2jcIX91IOoIo8WiT5C6qaTBobp4h/2RFN2Ppj2CJe3wj+rpT5QYfQRiAC/y/yU55y1N8zxr7bD2LvI86JhQBihThEVpYGMs9+r5B6g0txnYnyuyYQg7MiuTFk/PoeDmpySGN1rWZ/cmj1CfcdkOMloBBroJjMl6+eDX5cFbjn4YEEV25bznNB1mYE65qahcYw+7J7vPcDFKVMC3FbMxOd0/Ld+iYLB+btZrbw2cGplgxmAo6tusi1VAC0P3a4R59c446dVy+dZmZ41ufotbpQvGEphcwsXbCbvb24BISc8nSpOdkGjrUIfps3hV27uj/BZEHtuMoBmkh32eWfHm95dsDO6uPa8ON8r X-Forefront-PRVS: 083691450C X-Microsoft-Exchange-Diagnostics: =?utf-8?q?1=3BDM3PR12MB0745=3B23=3A58A8e4e?= =?utf-8?q?nf/UekUV3b/lZtKZoucpyyuZVYRFuVDW22kVC/0e/67OIn/kkcyUkhDPFHuFKZ0qd?= =?utf-8?q?eGuXOGuv/xa1CZmH8c4WX23NyngohnjNosTFXLE16cN4/sPGsGDskExdh+n4w0nO/?= =?utf-8?q?iLm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F8OdBrs25NlaAKtrynRJ7PoEAlfp8mPUxzaq+C1VXpXdJ1kUIiGqL+lUVUOBZifmW0EZifWFyxk1xDXAM5obAj7oW93i/jD0XvPCWNqC2uv9dzzorjTWNjsdb2KHQ64oLFrsNmH2Zmistg3VR+Aj37BAfZH4+TgV8tDlc1NIELWag==; 5:EipJsqY7shqetdaSi7rerw+jVkPmhd8GKQxYXACOl0B3SqEUTHMpkKxla2EVFKkM2PXmtMQjLKvyKn0SGTcCkiG6tYPqf/QrkfG7wPCPH73tuYMffEoBFzYhPLZg8otLBrRjc7Lojs/ZEe9VuuzWxLJAKIrYgnW8r8wgCJVCuR4=; 7:+CYfsSTolCo93LPsa4ysyeQBP1n5XjJoI7XttvIZrGPwL19KNyjGMYRVoOXyt4dKncIBux6Gi6Z6C9JAKn22DMtjOT+Mr1fhZi2j6+Q/3yMaR8yRFJPPotPd0ey60VxAc8qKarsigPURROnmrHlrr128RcMHXVstc/aTzvUrZgk4wIUOz1B/nXQnu1whGszQys+i2rj9FBdRiFV/o6k4VXFYss45DQSKN19gZhZIo/l15pySskqBNrz1ZKP2znCy SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM3PR12MB0745; 20:LWrNogKe5si54N/9YW6JI+JVryXAB+T00xAlBO1OoVFTimB+858DLBMpxHnDPl50Xr3expbdTAv1P8RvmxSVsgrm6esX+hG+tLiXPt91OCIJzW+BGf1mkLBJ+2LJyZoVxFX1Z1dCaCnC4PIM775Xo84mXKe/mBFNNW+zWQBvejS5caWB2CaLZIbIn40fRKAihrhVIzqMCGNNSMbkFv5opm6ND+rRA3pqsFPrHx+fRBq5QNnETaReB1cjZIQ3+30Y X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Oct 2018 15:08:39.3860 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7b660748-d3e2-4e58-faa7-08d63a8bbed0 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: DM3PR12MB0745 Subject: [Intel-gfx] [PATCH] drm/syncobj: Avoid kmalloc(GFP_KERNEL) under spinlock X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Chunming Zhou , intel-gfx@lists.freedesktop.org, =?utf-8?q?Christian_K=C3=B6nig?= , Julia Lawall Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP drivers/gpu/drm/drm_syncobj.c:202:4-14: ERROR: function drm_syncobj_find_signal_pt_for_point called on line 390 inside lock on line 389 but uses GFP_KERNEL Find functions that refer to GFP_KERNEL but are called with locks held. Generated by: scripts/coccinelle/locks/call_kern.cocci v2: syncobj->timeline still needs protect. v3: use a global signaled fence instead of re-allocation. v4: Don't need moving lock. Don't expose func. Tested by: syncobj_wait and ./deqp-vk -n dEQP-VK.*semaphore* with lock debug kernel options enabled. Signed-off-by: Chunming Zhou Cc: Maarten Lankhorst Cc: intel-gfx@lists.freedesktop.org Cc: Christian König Cc: Chris Wilson CC: Julia Lawall Reviewed-by: Chris Wilson --- drivers/gpu/drm/drm_syncobj.c | 41 ++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c index b7eaa603f368..fab0a2cf672e 100644 --- a/drivers/gpu/drm/drm_syncobj.c +++ b/drivers/gpu/drm/drm_syncobj.c @@ -80,6 +80,23 @@ struct drm_syncobj_signal_pt { struct list_head list; }; +static DEFINE_SPINLOCK(signaled_fence_lock); +static struct dma_fence signaled_fence; + +static struct dma_fence *drm_syncobj_signaled_fence_get(void) +{ + spin_lock(&signaled_fence_lock); + if (!signaled_fence.ops) { + dma_fence_init(&signaled_fence, + &drm_syncobj_stub_fence_ops, + &signaled_fence_lock, + 0, 0); + dma_fence_signal_locked(&signaled_fence); + } + spin_unlock(&signaled_fence_lock); + + return dma_fence_get(&signaled_fence); +} /** * drm_syncobj_find - lookup and reference a sync object. * @file_private: drm file private pointer @@ -111,24 +128,12 @@ static struct dma_fence uint64_t point) { struct drm_syncobj_signal_pt *signal_pt; + struct dma_fence *f = NULL; if ((syncobj->type == DRM_SYNCOBJ_TYPE_TIMELINE) && (point <= syncobj->timeline)) { - struct drm_syncobj_stub_fence *fence = - kzalloc(sizeof(struct drm_syncobj_stub_fence), - GFP_KERNEL); - - if (!fence) - return NULL; - spin_lock_init(&fence->lock); - dma_fence_init(&fence->base, - &drm_syncobj_stub_fence_ops, - &fence->lock, - syncobj->timeline_context, - point); - - dma_fence_signal(&fence->base); - return &fence->base; + f = drm_syncobj_signaled_fence_get(); + goto out; } list_for_each_entry(signal_pt, &syncobj->signal_pt_list, list) { @@ -137,9 +142,11 @@ static struct dma_fence if ((syncobj->type == DRM_SYNCOBJ_TYPE_BINARY) && (point != signal_pt->value)) continue; - return dma_fence_get(&signal_pt->fence_array->base); + f = dma_fence_get(&signal_pt->fence_array->base); + goto out; } - return NULL; +out: + return f; } static void drm_syncobj_add_callback_locked(struct drm_syncobj *syncobj,