From patchwork Thu Oct 15 07:36:34 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 7403571 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A11B99F1B9 for ; Thu, 15 Oct 2015 07:34:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C6352207EB for ; Thu, 15 Oct 2015 07:34:17 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 6B14A20782 for ; Thu, 15 Oct 2015 07:34:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3244F7A0E8; Thu, 15 Oct 2015 00:34:13 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wi0-f182.google.com (mail-wi0-f182.google.com [209.85.212.182]) by gabe.freedesktop.org (Postfix) with ESMTPS id 562287A0E8 for ; Thu, 15 Oct 2015 00:34:09 -0700 (PDT) Received: by wijq8 with SMTP id q8so115936169wij.0 for ; Thu, 15 Oct 2015 00:34:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=A8SlXN/z0AQVQPNPYicFMhnHk6yooNAfNGF2P4aV8Kc=; b=YBc7ULSwNsafiWV3Dp17OrnV491Tfikm+BSDHfWcvnM3QMMxPQft5aI+JzwoGifMwz FfcgGTmbOb4k0fH1O4K1TxgKQKARxVVSXMkjNlLZvEesuYHHSfluzXa0+bpbBNkSiZuC Phn+t1TrjgSVP9LkZNmrRJJ8MLGCZEIrRtHyI= 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:in-reply-to :references; bh=A8SlXN/z0AQVQPNPYicFMhnHk6yooNAfNGF2P4aV8Kc=; b=AB2QF7VIiecuYanSWro2+5jMQETn8XXdoVHaKmgDRnzZxdSLK0uXthRiJm5b3cl1TS G+ptlz1p8RHfnOvOdHCptb9fBSkvSSJrs4Pbup5LMOczNj9rQWkLPYrZNzHhFzWYwKUi ieAsW8uqvy6Fcdh4Yo+j83+2ACG5wii1f1OYGjpqHaZLvoafN0CZlZkhRND7Er0G2zKI RS1oKPFwgFHPPtpYUioy/Lxw6E122RU8cJicsZ4XCe2zF9UbK1otv2RU0uoWJ4uTlD6j 1yz0CQlxKDXZp3n6ZHlLJHsGyWLEc6gdblXSrj9ZHeqH4exzrggQTyC82PF0uspvafcE gX6A== X-Gm-Message-State: ALoCoQmZBo7GCNPvnWkRfMvpdEXDlkbn644iwjGznZJwac01wq/UtRuFDolsZV0xqp7qtl2SHQnu X-Received: by 10.194.90.16 with SMTP id bs16mr10195509wjb.37.1444894448058; Thu, 15 Oct 2015 00:34:08 -0700 (PDT) Received: from phenom.ffwll.local (212-51-149-109.fiber7.init7.net. [212.51.149.109]) by smtp.gmail.com with ESMTPSA id z4sm10201014wjz.29.2015.10.15.00.34.07 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 15 Oct 2015 00:34:07 -0700 (PDT) From: Daniel Vetter To: DRI Development Subject: [PATCH 18/25] drm/radeon: Use rdev->gem.mutex to protect hyperz/cmask owners Date: Thu, 15 Oct 2015 09:36:34 +0200 Message-Id: <1444894601-5200-19-git-send-email-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.5.1 In-Reply-To: <1444894601-5200-1-git-send-email-daniel.vetter@ffwll.ch> References: <1444894601-5200-1-git-send-email-daniel.vetter@ffwll.ch> Cc: Daniel Vetter , Daniel Vetter 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-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This removes the last depency of radeon for dev->struct_mutex! Also the locking scheme for hyperz/cmask owners seems a bit unsound, there's no protection in the preclose handler (and that never did hold dev->struct_mutex while being called). So grab the same lock there, too. There's also all the checks in the cs checker, but since the overall design seems to never stall for the previous owner I figured it's ok if I leave this racy. It was racy even before I touched it after all too. Signed-off-by: Daniel Vetter --- drivers/gpu/drm/radeon/radeon_kms.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/radeon/radeon_kms.c b/drivers/gpu/drm/radeon/radeon_kms.c index efa45e502975..893cf1079552 100644 --- a/drivers/gpu/drm/radeon/radeon_kms.c +++ b/drivers/gpu/drm/radeon/radeon_kms.c @@ -181,7 +181,9 @@ static void radeon_set_filp_rights(struct drm_device *dev, struct drm_file *applier, uint32_t *value) { - mutex_lock(&dev->struct_mutex); + struct radeon_device *rdev = dev->dev_private; + + mutex_lock(&rdev->gem.mutex); if (*value == 1) { /* wants rights */ if (!*owner) @@ -192,7 +194,7 @@ static void radeon_set_filp_rights(struct drm_device *dev, *owner = NULL; } *value = *owner == applier ? 1 : 0; - mutex_unlock(&dev->struct_mutex); + mutex_unlock(&rdev->gem.mutex); } /* @@ -727,10 +729,14 @@ void radeon_driver_preclose_kms(struct drm_device *dev, struct drm_file *file_priv) { struct radeon_device *rdev = dev->dev_private; + + mutex_lock(&rdev->gem.mutex); if (rdev->hyperz_filp == file_priv) rdev->hyperz_filp = NULL; if (rdev->cmask_filp == file_priv) rdev->cmask_filp = NULL; + mutex_unlock(&rdev->gem.mutex); + radeon_uvd_free_handles(rdev, file_priv); radeon_vce_free_handles(rdev, file_priv); }