From patchwork Sun Oct 23 18:31:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grazvydas Ignotas X-Patchwork-Id: 9391151 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 40D3460762 for ; Sun, 23 Oct 2016 18:32:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 342F028B2A for ; Sun, 23 Oct 2016 18:32:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2900C28B2E; Sun, 23 Oct 2016 18:32:09 +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=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, 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 E59D328B2A for ; Sun, 23 Oct 2016 18:32:08 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 739286E219; Sun, 23 Oct 2016 18:32:04 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-lf0-x241.google.com (mail-lf0-x241.google.com [IPv6:2a00:1450:4010:c07::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id C29666E0F5; Sun, 23 Oct 2016 18:31:53 +0000 (UTC) Received: by mail-lf0-x241.google.com with SMTP id b75so9416157lfg.3; Sun, 23 Oct 2016 11:31:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=1ccuHV7cK9qV2NcnqL8r36kD/tXyn4eoUQxXTyORKu0=; b=Yva1BLLsN15ouLklW3JBftRpqzRFoLjsd9pEBUFLlSZ3GWfNuxrtHTphXeFZqz7YzU Ph6nWOzEQ5s3zMLgAJ83qLUcH4jBR4k+80AAfxD/JuENO0LkOyHNI3CorVsL4w4QSZY3 FUruM/UO1PQu4I6AAMWSVY84rScl4vyUwpb1yOZViwS80Mtf4PZukdfh1d+QnRinfqki DSvFulMiWXjRBoxyy+FiZ6kPy1vuy3UUW7qgK+nOG62iqz1l7sEH23EiwzL2rJA9VxTf QhHwvN0YUBdWCJ/EDD1J3D6VffHzDaMnwxtb2cmR0vigHSirRJrwS2QcPkO6e9QwDYrE CYRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=1ccuHV7cK9qV2NcnqL8r36kD/tXyn4eoUQxXTyORKu0=; b=HGcljEkmCy1rQQh4Nq1CsMu60fux8UtfnBHqmxpcNqa8NCaK8ZlQcBlXJ2DlI0Ifc9 btEhBy0+CHsm5igXul0/Y5I4BtLC8YqpTVi6x4X+SXjiAXHuVjd0GhB6VouOcuf0Uuj8 oRnO4eIQM76N7i0Hc0CKgL1in+nbIN2XfizcHy4X5EId0HOuhbIL32GpgU1CsGkzc6YD 5L163PbLLnwYqh9OGBUOBV0mHJLPFGxhFsT58ABysWJhco5mavIq3tDapqcJyDPw8qTP 1F0inCmMHG6zksJ+1Sn20TktbwWHI3gEtK35IGpMiSaM6eJL6FH56HTjqTFiR0MrbFse 3c+Q== X-Gm-Message-State: ABUngveZku/qFvQPOs3lcZUF66qDH5wPpT7cnaik50DgEe5HdzqzSky2mod8Y8+85HfpIg== X-Received: by 10.25.19.74 with SMTP id j71mr4290559lfi.154.1477247512000; Sun, 23 Oct 2016 11:31:52 -0700 (PDT) Received: from localhost.localdomain ([5.20.238.37]) by smtp.gmail.com with ESMTPSA id 79sm2362855lja.16.2016.10.23.11.31.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 23 Oct 2016 11:31:51 -0700 (PDT) From: Grazvydas Ignotas To: dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org Subject: [PATCH] drm/amdgpu: fix fence slab teardown Date: Sun, 23 Oct 2016 21:31:43 +0300 Message-Id: <1477247507-11378-1-git-send-email-notasas@gmail.com> X-Mailer: git-send-email 2.7.4 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP To free fences, call_rcu() is used, which calls amdgpu_fence_free() after a grace period. During teardown, there is no guarantee all callbacks have finished, so amdgpu_fence_slab may be destroyed before all fences have been freed. If we are lucky, this results in some slab warnings, if not, we get a crash in one of rcu threads because callback is called after amdgpu has already been unloaded. Fix it with a rcu_barrier(). Fixes: b44135351a3a ("drm/amdgpu: RCU protected amdgpu_fence_release") Signed-off-by: Grazvydas Ignotas Acked-by: Chunming Zhou Acked-by: Chunming Zhou --- drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c index 3a2e42f..77b34ec 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c @@ -68,6 +68,7 @@ int amdgpu_fence_slab_init(void) void amdgpu_fence_slab_fini(void) { + rcu_barrier(); kmem_cache_destroy(amdgpu_fence_slab); } /*