Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3134483ybi; Thu, 18 Jul 2019 21:42:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqz6ElAjHwBMCgcsmdMOyjy04Ur5gryl9h3pV8ESjOwibn4nBrnuaXV0xLvh0xUle9JStFxf X-Received: by 2002:a17:90a:1b4c:: with SMTP id q70mr53814225pjq.69.1563511338990; Thu, 18 Jul 2019 21:42:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563511338; cv=none; d=google.com; s=arc-20160816; b=XoJanOc/JREga4OLVXrJ5AvSsCJJEviG+NYui2ky4kTrnp17oacuKaIGmo4/K5/1JX ndfsQ6ApzzI3BfHGK59C5DgLuDAXDx7x82ynFfz5yYINsyWLM0nxweUZjGOksTSkLGO8 TlFp8NLaKr8DkHb+yNEokq4geHpkg1wy8Oji54G8Z9+RDvBCqkHQ381JzzG7rlmUvewa 4VlpYjICWI6xTU46A7PNGzIRXqY/QDQLnqfdT4McSfImwYxxmIrY362I7vrElt37pEiR RaRFLpim2bHB2QCugBatjU2q+x4b/htgBUeivxMyMTfFGy86SMTH1KZzQcA90MkoVWO0 9XNQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=xtUrW1Isjd7WJg5ou3JEfBJgnonLJ0RzxNW6o1LWTMs=; b=qnfcfC3/0/bOUZyBJ2uHhcgz8Ud1krTepfjk1bclhOtwcqOM+uADrrw/rLcTFAgAvv zeEbFIDGyGyPezAguci9aQF9s3YR3CSON+dwKGX/vHvQ8HKhMbh3q93tntyLeu/OGxaT j033DYeyKxBRYvUiH8IteSSyEYhM0l0SkEyMtu0N2icv6fvVyIDyU2LTL2xKR9tPnc6N 0wjWlyuKVhJDbE2K4wlmOMPprlpSG/GyApajUrzWM5y7E22614KTJ8059Km/q63G7oFD OyWme0wzt/Jl5UssA6NTO92X5KfHSv/cqxOZyEvYqfMOOeaBOnfbkPhMEVmbMWEwNR2Y 9EoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ow8sr7fh; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f61si1461788plf.258.2019.07.18.21.42.03; Thu, 18 Jul 2019 21:42:18 -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=ow8sr7fh; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728059AbfGSD60 (ORCPT + 99 others); Thu, 18 Jul 2019 23:58:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:57676 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728003AbfGSD6X (ORCPT ); Thu, 18 Jul 2019 23:58:23 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6352021874; Fri, 19 Jul 2019 03:58:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563508702; bh=guzUZgOKDvGjX7Bi80hdbzQK5EMcnZJJ7C5EuFWknyo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ow8sr7fhJGSmdhbgf4lFiDrdnuPY9eq3TqQrwKtihwr1ygPySzrvKzVaiLxAiHb6R Z7WUGSv/zdK8mwp3lK+br6/Z7WeqMW+PcAEzO2vZLsxVtTrqiqPXDa6rBv/e/oOJf3 PQN4iCPF/79znX2kRBcxNxcOP1oo3jfxaPqLirjM= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Daniel Vetter , Rodrigo Siqueira , Tomeu Vizoso , Emil Velikov , Benjamin Gaignard , =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= , Daniel Vetter , Sasha Levin , dri-devel@lists.freedesktop.org Subject: [PATCH AUTOSEL 5.2 041/171] drm/crc-debugfs: User irqsafe spinlock in drm_crtc_add_crc_entry Date: Thu, 18 Jul 2019 23:54:32 -0400 Message-Id: <20190719035643.14300-41-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190719035643.14300-1-sashal@kernel.org> References: <20190719035643.14300-1-sashal@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Daniel Vetter [ 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