Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3815660ybi; Mon, 29 Jul 2019 13:10:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqzfUvpleRSq4dpVWa/V5a6LAq//ozSTOWlCq2TNybg4U4401N1amYF5DEgYDLX67fOIfrUm X-Received: by 2002:a17:90a:eb08:: with SMTP id j8mr78480176pjz.72.1564431022203; Mon, 29 Jul 2019 13:10:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564431022; cv=none; d=google.com; s=arc-20160816; b=basfzPbbjHkHLSejiyYG0I/eg51Oll1Ml8CKMYQEv/ODZuw+bt3Z/4wBnWgQRcdMAM gruXjo7Q8uUFk2+KCOEkrY80lnrN1t9P0VW4dccBGYSdhC0EUu18ERjHpYyn7jr0DArL oHWqzzFi5TuepiIa73EsKCJo7x7ss5ZPVbvn2K9WMayAlLRY35qqmnh1hD/Mn+M5yj9o 4J6yFBL1tQu2BDhhTL5Rj6SQSQvyLQlMdjxhEsgr8U2YwE72HKc77uhANcfeFZMH6nlM BejEZxUHSAhzzNEEv59ZwJuIDu8S1tQXPcYREloN6W8kmtpIBXr5w7ho7R7RQprV+xf4 Wj/w== 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=YJ4jCOT7EHZN0t6vO8xjTvrTHPItDtsa/uBb8fSCCkY=; b=BRpFVCXU1e+ZsiCydKmqKhnmXoI5RLps7iUMheN3teMXaDbTzXyPNT2IznOv87NkX7 jxTJvwaDbLhwEtcpN+eo7QdyLYjDQCXo9YN4mNQE7JOrZBauoxGOEBKxR7chVEByuUZK 2qhgMAP9HO+8OuFHqdUTk0zKh5WQsdEA4llQmS76/M6ZfuxnvBC2hlgUPNq5zFNLurVq uamTEq+eRuCbMHqcPSp3HqbaX/PeIUbNzrPW3sd/yuBh6Lj2xmIuSuOYmPw4jnLaxi0G TnlPxFgqOV2zc20Dp/zqUPsBIKN7ukRtlGNpf3dbT0gKlLmZ8D9bIAbx+pegqW2xvzyA O1Yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cGsJ9FJe; 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 k10si27930727pjw.1.2019.07.29.13.10.07; Mon, 29 Jul 2019 13:10:22 -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=cGsJ9FJe; 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 S2388115AbfG2Thg (ORCPT + 99 others); Mon, 29 Jul 2019 15:37:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:52380 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388723AbfG2Thd (ORCPT ); Mon, 29 Jul 2019 15:37:33 -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 E135C217F5; Mon, 29 Jul 2019 19:37:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564429052; bh=OM+oao33KGs0GJ/R8HaZfy5nw4JYJb8g+JBCHwjDJm8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cGsJ9FJeqDcuAhbtL1dBr15rafB7mb32z+ni0w0I0+tRqJHDEX+8jhIHn2ncClSs7 m4zKxz9Y/Sd+p9HL3LhdlTwzMa3LPTBwDrXTmzvy/R9k4nhy7ZdSYPvRWqOBx3QWa5 4q0czrqyP4dgXG9zBVN4fKHkc/EoUL3cjE05RJy0= 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 4.14 231/293] drm/crc-debugfs: User irqsafe spinlock in drm_crtc_add_crc_entry Date: Mon, 29 Jul 2019 21:22:02 +0200 Message-Id: <20190729190842.182992398@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190820.321094988@linuxfoundation.org> References: <20190729190820.321094988@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 f9e26dda56d6..021813b20e97 100644 --- a/drivers/gpu/drm/drm_debugfs_crc.c +++ b/drivers/gpu/drm/drm_debugfs_crc.c @@ -359,8 +359,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) { @@ -385,7 +386,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