Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3796721ybi; Mon, 29 Jul 2019 12:48:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqzkp7hObqYR2EbBDpt4j0Zfu+bpG2qFX9+untnlIANH6H4DIyalfzxaBwPhBXUR7PsRJExo X-Received: by 2002:a17:90a:3463:: with SMTP id o90mr116219744pjb.15.1564429712623; Mon, 29 Jul 2019 12:48:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564429712; cv=none; d=google.com; s=arc-20160816; b=otCmSAhi5OuK0Qej5XLALf0bG6QZMqACL4fOsXN9NoymvTfhB93itHrcxJ2nTsohrc p7z9QDAO6s43NAaycAz1w8pjSTrK6A4yvTYiXhf6rTtms/YnxCuQX5vDm/O2MNKgbOXH eBA1OAk0zEJx/eE/M9LjYhK7UYcE4KdSSK0S3lccQ3QLdNQjOdfk7SiO5Dd9CgLE+rvH WNxafIuohmnd0f1DN/KQB4DXFIOXKevipjNqM0I0xcrlFBLgGVlE+8XXXIH67FBDzSPN 32RU1esVboARpqf3SibpIbEgJWDvyJIP44i/OScnjish6BJGAPfnDiJPd4igichpXOYU HyQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=8TyE5oBZZNw+/TYD2tSKCOt7hu+12ekb4wMMoPIDZcU=; b=sC70ce07+TesHflbKljIzDpJM1fzash8V1vZLrDatcMIFdJRmjgcZmwdgiaEHjoKDI +F5lXtDEac2Zhb9dN49UNfpkgTZpoXCcL3mbtds3NPizKmME3IEOJslfXqAf3Hi7ROvE uv+eIGP7sDRfoNwSKAcnIIg4oAFpFkGXQ1y/Dl+Djf7o/scN3UfRaXwQw5D4W/T4g50i 0WZ3f5il1u++6xCu6/XDNdCoPD9mOteci4rn6zidMg2Y3rYYBwzy05U74TDF+X6EuYq5 RA+Glubxnc9mIjlwdf1jta4CbVKhKGx5wnkOAxtyc5H/YMTUZRKFdjahBsGnJe1O3n6c 8YOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FbAjzzKm; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d10si26572472pla.135.2019.07.29.12.48.17; Mon, 29 Jul 2019 12:48:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FbAjzzKm; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390295AbfG2TrE (ORCPT + 99 others); Mon, 29 Jul 2019 15:47:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:36594 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390287AbfG2TrD (ORCPT ); Mon, 29 Jul 2019 15:47:03 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 39FB8205F4; Mon, 29 Jul 2019 19:47:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564429622; bh=2Px9ymgNTbeq+puEgqK5I+LQr4dA8DZ2DNbMkVJdFLc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FbAjzzKmO91ccYTipWTwnTklLglxMYCIvfZmHkjmaeKgtdkz82b/o12A1VXheBsHN z7FUHdGTogHSikLKEsjbulLkDUr1le3N4NMpei4oJI0KkmQe0tMYCr18Bj9IVn34zE FSds74hnEoDtPX5eFFvjQ/dg7AgEc/9b4IDflD4Y= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Rodrigo Siqueira , Tomeu Vizoso , Emil Velikov , Benjamin Gaignard , =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= , Daniel Vetter , Sasha Levin Subject: [PATCH 5.2 043/215] drm/crc-debugfs: User irqsafe spinlock in drm_crtc_add_crc_entry Date: Mon, 29 Jul 2019 21:20:39 +0200 Message-Id: <20190729190747.977638588@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190739.971253303@linuxfoundation.org> References: <20190729190739.971253303@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 1882018a70e06376234133e69ede9dd743b4dbd9 ] We can be called from any context, we need to be prepared. Noticed this while hacking on vkms, which calls this function from a normal worker. Which really upsets lockdep. Cc: Rodrigo Siqueira Cc: Tomeu Vizoso Cc: Emil Velikov Cc: Benjamin Gaignard Reviewed-by: Benjamin Gaignard Reviewed-by: Ville Syrjälä Signed-off-by: Daniel Vetter Link: https://patchwork.freedesktop.org/patch/msgid/20190605194556.16744-1-daniel.vetter@ffwll.ch Signed-off-by: Sasha Levin --- drivers/gpu/drm/drm_debugfs_crc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_debugfs_crc.c b/drivers/gpu/drm/drm_debugfs_crc.c index 00e743153e94..1a6a5b78e30f 100644 --- a/drivers/gpu/drm/drm_debugfs_crc.c +++ b/drivers/gpu/drm/drm_debugfs_crc.c @@ -389,8 +389,9 @@ int drm_crtc_add_crc_entry(struct drm_crtc *crtc, bool has_frame, struct drm_crtc_crc *crc = &crtc->crc; struct drm_crtc_crc_entry *entry; int head, tail; + unsigned long flags; - spin_lock(&crc->lock); + spin_lock_irqsave(&crc->lock, flags); /* Caller may not have noticed yet that userspace has stopped reading */ if (!crc->entries) { @@ -421,7 +422,7 @@ int drm_crtc_add_crc_entry(struct drm_crtc *crtc, bool has_frame, head = (head + 1) & (DRM_CRC_ENTRIES_NR - 1); crc->head = head; - spin_unlock(&crc->lock); + spin_unlock_irqrestore(&crc->lock, flags); wake_up_interruptible(&crc->wq); -- 2.20.1