From patchwork Sun Oct 23 18:31:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Grazvydas Ignotas X-Patchwork-Id: 9391155 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 1C2AC60762 for ; Sun, 23 Oct 2016 18:32:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0F0C928B2A for ; Sun, 23 Oct 2016 18:32:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 03B0E28B2E; Sun, 23 Oct 2016 18:32:15 +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 B7EE228B2A for ; Sun, 23 Oct 2016 18:32:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 665836E2E3; Sun, 23 Oct 2016 18:32:11 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-lf0-x243.google.com (mail-lf0-x243.google.com [IPv6:2a00:1450:4010:c07::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id 054006E0F5; Sun, 23 Oct 2016 18:31:55 +0000 (UTC) Received: by mail-lf0-x243.google.com with SMTP id x23so9162246lfi.1; Sun, 23 Oct 2016 11:31:54 -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=DWTtNI/GV7UW8dVsgSEPF3J5d9ONleSA42cGj8NDzR4=; b=x2r2jY+b3yRi5qhq5m0AksOkQ5nA84K8H+lcFQwYUeXtpQypPS3JxiDpNfZCKwpygy t8WzwBMgVB2PnQkt08EouE04PqZ5/JdUPKFnzhCJS0fpWaOw8RqBUikCeleCkcBME6CR NS+LxwIkN5pfWwQAE76fZpyQS+pngsZ8Bzufl55io7q/xM98Ump1kRfYR5mMNovM28/g GJCblI4kYcDfCRvuDhw19Tzt/wHnN3OTTvy79hKmgTpbPCPy4bpVW+6AqydvUAsgEmbx zwTHNsnpxPSF0ENwLOmApLWGBn7wvYSazFPHKjYAuxDCHT5wIOw5eY0ZX2N66chLKs1+ H6Gg== 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=DWTtNI/GV7UW8dVsgSEPF3J5d9ONleSA42cGj8NDzR4=; b=QOyAW9PTPCqP1H89kuVswgxeBQpA93b/HmwV/ceyB3ruB0ah/EpQIuHeS5Eep6JbM4 AzKJFz26DHYJ+lL6kgupxhY/ZpBjW2lpTtg/ma81QceTaKDM262BzYEBJRJTERimTyWW 1k2WkotXuYp3ULeSx/KeeYOPHHvBca+ZtYGEe9AnnjLfGu1JF3MDlja9BwxtBgwcir1B STD1jCSRvwDZQ1nFRrf0usyPQK7iykcc5b7rnAlKZs3h9j50P+/dWCUAGcPk7hRZ61Ax 7KViDXOe+1/TAYXq4XWwiENsTYCj/Tps3f7n2juXHGXGVwFV5oBepT/RjEAoT27V9qWt VSuw== X-Gm-Message-State: ABUngvf4OaWxNr9whyOE8K5P8hk9qjZhmK9/rJgNtfqi2sfD3jjFknhkhmsG680Jdfj6Dg== X-Received: by 10.25.41.205 with SMTP id p196mr5001588lfp.2.1477247512913; 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.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 23 Oct 2016 11:31:52 -0700 (PDT) From: Grazvydas Ignotas To: dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org Subject: [PATCH] drm/amdgpu: fix sched fence slab teardown Date: Sun, 23 Oct 2016 21:31:44 +0300 Message-Id: <1477247507-11378-2-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 amd_sched_fence_free() after a grace period. During teardown, there is no guarantee all callbacks have finished, so sched_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: 189e0fb76304 ("drm/amdgpu: RCU protected amd_sched_fence_release") Signed-off-by: Grazvydas Ignotas Acked-by: Chunming Zhou Reviewed-by: Christian König --- drivers/gpu/drm/amd/scheduler/gpu_scheduler.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/drm/amd/scheduler/gpu_scheduler.c b/drivers/gpu/drm/amd/scheduler/gpu_scheduler.c index 963a24d..910b8d5 100644 --- a/drivers/gpu/drm/amd/scheduler/gpu_scheduler.c +++ b/drivers/gpu/drm/amd/scheduler/gpu_scheduler.c @@ -645,6 +645,7 @@ void amd_sched_fini(struct amd_gpu_scheduler *sched) { if (sched->thread) kthread_stop(sched->thread); + rcu_barrier(); if (atomic_dec_and_test(&sched_fence_slab_ref)) kmem_cache_destroy(sched_fence_slab); }