From patchwork Thu Aug 2 16:05:42 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Glisse X-Patchwork-Id: 1267811 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork2.kernel.org (Postfix) with ESMTP id 87B12DF223 for ; Thu, 2 Aug 2012 15:45:25 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6C7F5A0CB0 for ; Thu, 2 Aug 2012 08:45:25 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-yw0-f49.google.com (mail-yw0-f49.google.com [209.85.213.49]) by gabe.freedesktop.org (Postfix) with ESMTP id 697CFA0CB0 for ; Thu, 2 Aug 2012 08:44:20 -0700 (PDT) Received: by yhjj52 with SMTP id j52so9225883yhj.36 for ; Thu, 02 Aug 2012 08:44:19 -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:x-mailer; bh=LH0vptXGh2FA3LGQwHOyNMTwMw2U/qTncWRbYpb/Wn4=; b=z0m2EihAqdw4ibGyx4TnmOxtvMbwokBqJEdHPKP8OhV1fq49Qrjx5hS/UZAliEILcb FFi1o9u9sRwTmqk5e/B0iopjbL/UVMEOTpqTboaijN+H4odpRUGP2FpMLXmbfegW8+BW z47Rhd9mjBb3HumBPT1dOv6XdCcBYTRF0yxblZXBaT8pQk3jnEY7sdA/9rmuWmmA6tMr PqREWT7dDwnirO3kUmX7v2jJ+MIUl3yvRPqry1xJmrmxrVifLE8ZWIpSxec7OHGwL1em SMA+UGpySczPiNt6nLeVgF8U9RVKSC30Z2gHlj4M74Kq2reaJL7z/tRfIJ2jxihS3Eza lfXw== Received: by 10.50.196.232 with SMTP id ip8mr4444531igc.50.1343922259521; Thu, 02 Aug 2012 08:44:19 -0700 (PDT) Received: from homer.localdomain.com ([66.187.233.206]) by mx.google.com with ESMTPS id ay5sm17457730igb.15.2012.08.02.08.44.18 (version=SSLv3 cipher=OTHER); Thu, 02 Aug 2012 08:44:18 -0700 (PDT) From: j.glisse@gmail.com To: dri-devel@lists.freedesktop.org Subject: [PATCH] drm/radeon: fix virtual memory locking in case of reset Date: Thu, 2 Aug 2012 12:05:42 -0400 Message-Id: <1343923542-830-1-git-send-email-j.glisse@gmail.com> X-Mailer: git-send-email 1.7.10.4 Cc: stable@vger.kernel.org, "[3.5]"@freedesktop.org, Jerome Glisse X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org From: Jerome Glisse Lock/unlock mutex in proper order to avoid deadlock in case of GPU reset triggered from VM code path. Cc: stable@vger.kernel.org [3.5] Signed-off-by: Jerome Glisse Reviewed-by: Alex Deucher --- drivers/gpu/drm/radeon/radeon_gart.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/radeon/radeon_gart.c b/drivers/gpu/drm/radeon/radeon_gart.c index b372005..7eabb59 100644 --- a/drivers/gpu/drm/radeon/radeon_gart.c +++ b/drivers/gpu/drm/radeon/radeon_gart.c @@ -508,14 +508,19 @@ static void radeon_vm_unbind_locked(struct radeon_device *rdev, while (vm->fence) { int r; r = radeon_fence_wait(vm->fence, false); - if (r) + if (r) { DRM_ERROR("error while waiting for fence: %d\n", r); + } if (r == -EDEADLK) { + /* release mutex and lock in right order */ mutex_unlock(&rdev->vm_manager.lock); + mutex_unlock(&vm->mutex); r = radeon_gpu_reset(rdev); mutex_lock(&rdev->vm_manager.lock); - if (!r) + mutex_lock(&vm->mutex); + if (!r) { continue; + } } break; } @@ -551,7 +556,9 @@ void radeon_vm_manager_fini(struct radeon_device *rdev) mutex_lock(&rdev->vm_manager.lock); /* unbind all active vm */ list_for_each_entry_safe(vm, tmp, &rdev->vm_manager.lru_vm, list) { + mutex_lock(&vm->mutex); radeon_vm_unbind_locked(rdev, vm); + mutex_unlock(&vm->mutex); } rdev->vm_manager.funcs->fini(rdev); mutex_unlock(&rdev->vm_manager.lock);