From patchwork Fri Oct 26 06:20:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chunming Zhou X-Patchwork-Id: 10656965 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 8F88D13A9 for ; Fri, 26 Oct 2018 06:20:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6DD322C2F0 for ; Fri, 26 Oct 2018 06:20:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5DB6B2C51F; Fri, 26 Oct 2018 06:20:39 +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 9B2CE2C2F0 for ; Fri, 26 Oct 2018 06:20:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BB6436E3F6; Fri, 26 Oct 2018 06:20:37 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from NAM04-BN3-obe.outbound.protection.outlook.com (mail-eopbgr680068.outbound.protection.outlook.com [40.107.68.68]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7AB316E3F5; Fri, 26 Oct 2018 06:20:36 +0000 (UTC) Received: from CY4PR12CA0026.namprd12.prod.outlook.com (2603:10b6:903:129::12) by CY1PR12MB0743.namprd12.prod.outlook.com (2a01:111:e400:59d1::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1250.30; Fri, 26 Oct 2018 06:20:34 +0000 Received: from DM3NAM03FT034.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e49::207) by CY4PR12CA0026.outlook.office365.com (2603:10b6:903:129::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1273.18 via Frontend Transport; Fri, 26 Oct 2018 06:20:33 +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 DM3NAM03FT034.mail.protection.outlook.com (10.152.82.192) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1273.13 via Frontend Transport; Fri, 26 Oct 2018 06:20:33 +0000 Received: from zhoucm1.amd.com (10.34.1.3) by SATLEXCHOV02.amd.com (10.181.40.72) with Microsoft SMTP Server id 14.3.389.1; Fri, 26 Oct 2018 01:20:32 -0500 From: Chunming Zhou To: Date: Fri, 26 Oct 2018 14:20:27 +0800 Message-ID: <20181026062027.12179-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)(396003)(136003)(346002)(376002)(39860400002)(2980300002)(428003)(199004)(189003)(104016004)(66574009)(68736007)(1076002)(1857600001)(86362001)(478600001)(2906002)(14444005)(26005)(97736004)(77096007)(54906003)(2870700001)(50466002)(50226002)(72206003)(8936002)(186003)(81166006)(81156014)(8676002)(5820100001)(47776003)(305945005)(486006)(2351001)(2616005)(126002)(476003)(356004)(6666004)(23676004)(7696005)(105586002)(426003)(316002)(106466001)(53416004)(336012)(5660300001)(6916009)(36756003)(53936002)(4326008); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR12MB0743; H:SATLEXCHOV02.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoDomainNonexistent; A:1; MX:1; X-Microsoft-Exchange-Diagnostics: 1; DM3NAM03FT034; 1:P50wiDmeGwbQOs+g9jPTIHy7mb9/kqwRQoSPFQkeQm1mQPw32pcSIPfIUZrdDE9uRvWn+zQQUPHbTrv227EHdj0ldI0+5nWavyOg6mVL3QxsgnbWodIyoC6zvHeUhZ6m X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f6821397-2396-467d-b25b-08d63b0b2313 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(5600074)(711020)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060); SRVR:CY1PR12MB0743; X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0743; 3:/e1AG1N1o8iGo8dNjUwo4a16AyYmmIOqy8jF2QGe5b8rSV2qdAXYf40eAPsoJgiee6CzfGa/uahC1nLSduirnNUVqeUEz7rmUQdrGrEZP4u8tfJ5CqHPuH9WBP6ev0kSEayqDM5ou10j8JgwkKfV5C6eW8JytJx7iC0bOoGRys6fiTit0RYqgeFSom+59i36OXxj9sTwHLTefQqDtYp/ZK6luD5obkCzLkZJ7kskdrGiBU8A8orlMUn6vbLIXk974H2gBHYOGodgMdk7PoROEVb04bW7VMJApzh97g48AuUPpYt9QZuEQetwqc6g2xsWbFzm8BjN18WiP080xW7k4gayFnqtebTZuoh8e5xtMVU=; 25:fnwsTTvNSTdyJ05dMfKE4WT8NZdEy5SoKV+ZEyXdE0tJID/D/NOh5jhTd4WLGEguHMSSRaqWOnLivL8+GlnLy1hZnueGIqZVD9sLa8L2xmkRPmZWnrdfhiOqkxWI8CkOId2eoclsSa47aV1zu0UZfHrEe7I1BQOkSf0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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)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201708071742011)(7699051)(76991095); SRVR:CY1PR12MB0743; BCL:0; PCL:0; RULEID:; SRVR:CY1PR12MB0743; X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0743; 4:HuUJl2qJ7zXMoaQLIkPBRgmbWREAbB4byfpz2PH091eFV8fPk3zQvS4h0LM3wXPbWyLYmTb7bNXx4C8zkYFEalHUGpwGj5VHtpu7p1Llf1vn2dxg8D5Ro2OWUvoWnrMQCeEUE4TrAaLIYFgM8SBKL+B5/H41swB1puBlLuuLVFuf2IWwvIbyVbHKAHuQAS4katM1pQjar5gMJN4+t2K2sJ1EjJhvUmiKB0B8ndIwFes3VOq9UYrCruptGgzMtYFhY2w7RSB9Bt14do/fsk9zVNW+vNLplP07VPRv0RxMSXMentiepqyg3/3BBoIzd6WB2M04iUoz627xY1hejsg9n7087/t2adu3wUVfcMIOPGR908qJ4n8bevzb0VrLv9hgsKG8PPdcnlYC/pivVLyxOEgo60sDTbgHKFigEHL1yvDHEowXE0bqb6VndnX66sBR X-Forefront-PRVS: 083751FCA6 X-Microsoft-Exchange-Diagnostics: =?utf-8?q?1=3BCY1PR12MB0743=3B23=3Ak7+4Sct?= =?utf-8?q?2OWlvxiVWQpk+GgiSMYEZ/HY9WQrqp5Ov1Sit4FInPVipNnd5xHZS58fh0wO2bZuD?= =?utf-8?q?6a/UyQ18X13w7pI0LjS5wKCraLgm+7ZyBJQVY1iNlNpzkwhh/CzQG7vR4QBokbKSu?= =?utf-8?q?xdxe1kmiLXEIKw1/Nw2anZHnh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1Rz5lHlC6uT4xobvrFAChk9jolFDtx6KYak0QuPJN6eyzdUxCnQg8FYpjRGzr8++B5Pe6TWmcx7SWBb79ZQ2G3WDhdxjKAw/36Vf73iCvm+FOJu3RWrBoies3PurJnAcBZX3c6QJtW5KVsUgCL2E566R93Fh6nvBqx57Bx97EM=; 7:XPZwNEgtSWhh7flUNoPzuex5pycwxzi6L9Sh376zXm+WHjrM8UzuLhG9CqX/RV3efQrbqWPbXPLB8K5EBuFSxonc3wdHnltMqEVvz9k/AnqQIzqxsQOak+EJs3g3lb7NNljlucizYXdH+EWV31BPN4IsNvCFhTJx2LD0yAZTSZPfAYyfDRKL8O3yE2C9cRGujjpU+2DnxDr7dF2rpGw+2T0I+pubwu25EWk3VfJ5gZGlks/X0vlpAO9JiDCg1l/p SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0743; 20:BIuiKo27Mmq+WV+Et08f15m9kySHTIt7MoeDswbvYu1jDGii7GRnI2d1zNvNp0T7gz/bDyhmD1tMIqVkmWsXfe0GOksyzosRdLAoUD3v+dKc9s+kDmyE7ak0O7TvezVYEev5wPKuaPWGaofOeDWVN4UfGd+W7s25Z2tzuSNYHeO8JjjLBW4mFhERInPbYA1KzioDUd2KHWJAHpoGzxqKIH5zSFtTAlZjp9N3tEKGs4/V0xY3xxngaLmV16teCccC X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Oct 2018 06:20:33.5238 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f6821397-2396-467d-b25b-08d63b0b2313 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: CY1PR12MB0743 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. v5: rename func and directly return. 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 Reviewed-by: Christian König Reviewed-by: Maarten Lankhorst --- drivers/gpu/drm/drm_syncobj.c | 36 ++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c index b7eaa603f368..d1c6f21c72b5 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_get_stub_fence(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 @@ -113,23 +130,8 @@ static struct dma_fence struct drm_syncobj_signal_pt *signal_pt; 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; - } + (point <= syncobj->timeline)) + return drm_syncobj_get_stub_fence(); list_for_each_entry(signal_pt, &syncobj->signal_pt_list, list) { if (point > signal_pt->value)