Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4101765ybi; Mon, 29 Jul 2019 19:17:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqze4xz8u6TyMNLZLbMeGYrW06NrUwzi6dNH1wAWF0dXdouFWWKvL4qWOhGEl/ne42f9JmcP X-Received: by 2002:a17:902:9689:: with SMTP id n9mr114702086plp.241.1564453023659; Mon, 29 Jul 2019 19:17:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564453023; cv=none; d=google.com; s=arc-20160816; b=FiY/jVQYkveX7BBw79L9p4PfacDIM7AA6XfCwzZt3YXdohcr8MvCDWfNjFSYRjOXhl 86mx7aw2jepR0RHzSEV0Hq/bTdlK+KPXGgzUK307HualRBj6cUiIkD2b6pTS7H5Ky7Vz qkqm/uGd9QSGlAVZbIjEwQR42/HHH7hXwj8MN1+15DGcsHv8CBsZkuNQX25+NpuSrJn0 EmusGVlZSLAUxmmPIZS3U1xbvF3vFYEpm4jjkP8yPxCEf9EA9XHfiPHJtnCAxsNtOiL9 HEPDgvrUMSioZPV+3yf9OpwgjTY4r7d9S+HAqIER8+44fjagWJqqM2UwjR8g/eyGZCJZ q7Ug== 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=LQZFwfNNqRLadWmPxwK0nChTZN2pOhYvpbKUe8cRMNY=; b=PFnx9AGEBChpGYFgRS8MpIiAlkkJ8yyjUxtfnu/45o2gRX5203FIDwq4SwQnMF5QRs qYSnSdrHdBsL5n0BhreyXXsBBOjFE/mBQhUe4D6fZav/+nKZWB9GHJzlHau3wTEWNc2g pmjcgCNaQtsibzAcsRKsWsUIicQ4K9m0a9gvKwZk4gAyTVbl3wv+VTWjPCR8FekGjrUv CGUCGhAUpQjHPjD9+B+WJ1+CZl6ta4W6DK4A+hP/ru0CtC4kg3oGRCamHhGW84eqAwdp 3FkRLa/DW0QgyEt+GuHriQgiFdbh7YXrkxNn8hA8djuvzPP/W9KnSy3pc+qK1lKQ7Hq4 5eFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hcySuAW8; 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 a10si28153254pfc.215.2019.07.29.19.16.48; Mon, 29 Jul 2019 19:17:03 -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=hcySuAW8; 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 S2389061AbfG2Tjz (ORCPT + 99 others); Mon, 29 Jul 2019 15:39:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:55078 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389039AbfG2Tjy (ORCPT ); Mon, 29 Jul 2019 15:39:54 -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 7FCC1217D4; Mon, 29 Jul 2019 19:39:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564429193; bh=H8AJYrVZIfb1kv/D0H3pFJb2xDfdmkq/qkgb0ea7t68=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hcySuAW8wzfwi+SK1HBJEgWFjwbdxaqUht3oJI48Y7p0R2vySMEpF2scFeEgWGYY6 +90RrKJRBQ6NcPdVgVpYu8US/YXBN0EFjQ3i+5AEiyI50h/3aApjgMiLBcm4BtviEs ZKxVEftyvXwGQHRbh1eIFZOJcMcizRNDJuasW1OY= 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.19 020/113] drm/crc-debugfs: User irqsafe spinlock in drm_crtc_add_crc_entry Date: Mon, 29 Jul 2019 21:21:47 +0200 Message-Id: <20190729190700.633359978@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190655.455345569@linuxfoundation.org> References: <20190729190655.455345569@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 99961192bf03..a334a82fcb36 100644 --- a/drivers/gpu/drm/drm_debugfs_crc.c +++ b/drivers/gpu/drm/drm_debugfs_crc.c @@ -379,8 +379,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) { @@ -411,7 +412,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