From patchwork Mon Jan 2 12:59:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomeu Vizoso X-Patchwork-Id: 89485 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp7579628qgi; Mon, 2 Jan 2017 04:59:53 -0800 (PST) X-Received: by 10.84.234.23 with SMTP id m23mr94657416plk.89.1483361993375; Mon, 02 Jan 2017 04:59:53 -0800 (PST) Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id s18si65628344pgd.149.2017.01.02.04.59.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Jan 2017 04:59:53 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE dis=NONE) header.from=collabora.com Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E0E6389DEC; Mon, 2 Jan 2017 12:59:49 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x244.google.com (mail-wm0-x244.google.com [IPv6:2a00:1450:400c:c09::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2CC1F89DE6 for ; Mon, 2 Jan 2017 12:59:47 +0000 (UTC) Received: by mail-wm0-x244.google.com with SMTP id l2so56548865wml.2 for ; Mon, 02 Jan 2017 04:59:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=JZJ1rCPF31amkM327kOxO+8t3rDr8Jbh+d8OnrI7BQc=; b=Y4Df5+vmRNpm7PtlM2T4JfecuyAs+DZ2iHcEbrOyVfI+h7U4PENo8+sD5Mtm3XvXQU D/WxRq5tRtcfUfsZ9O83ZGs6gzy2SFmXEzjeCREzLTZKGxiTXFUFQXVSAXyeS9l2oidd NQyH+Cad/0aXFxMNyenECp35xw7K/R1UIfXsxB9neHwFP7UlsG9MisQmAWL3QH1fdVhT YECQQxc9OyGar1MHgLZzpz+8IvRdXDQk7yJZ3greP6ro2AgaE7E7uKqQGyxfOOy6BXBN bU9yQpQwLstwYz10PcCZ11hnXvgz2uBBrsxawm8rNSI1wN6LN39zuSUUIFCryG0a1zeh Geww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=JZJ1rCPF31amkM327kOxO+8t3rDr8Jbh+d8OnrI7BQc=; b=oVAopVb4zfYg9iH4ZsycMr1ueADwLt4f1dIVCjFqU0PXzyjdGWdSx65qFE7qOqJqt7 V/9WqfgzoMnFU7RcxTg8b4fxhS3unz0WpPangFA+mJrVQVrQyJwRa3LUlL+sV3QMtLV7 SMwIOKmYYQ2kGTGQ7XZSDHxRx3JWh+uFVZpjJQOsfCww7jk6NWVwBJJW99N3pkrlyR+a wRSaLlRu2Whrb7B62KMzR76hlbyhoAjAkDJznYXxuwYZFbYel/Gmm7LLw1+1ZNhvsc1r UE3N3ldpwgnKDo4bXACt3eGCIQbpsKDr9rZXm1FxpZ7Ja9adHM02aoKetlXvpuPlfuiJ nrjg== X-Gm-Message-State: AIkVDXIid7k5uvV6njDG4Jc5bqaZ9NABvgKN4wiy/hZOpb0FFlf2hIBB7oAxVQD8np0NSw== X-Received: by 10.28.20.139 with SMTP id 133mr50754486wmu.9.1483361985358; Mon, 02 Jan 2017 04:59:45 -0800 (PST) Received: from cizrna.lan ([109.72.12.216]) by smtp.gmail.com with ESMTPSA id f126sm84058006wme.22.2017.01.02.04.59.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Jan 2017 04:59:44 -0800 (PST) From: Tomeu Vizoso To: linux-kernel@vger.kernel.org Subject: [PATCH v14 1/4] drm: Move locking into drm_debugfs_crtc_crc_add Date: Mon, 2 Jan 2017 13:59:09 +0100 Message-Id: <20170102125912.22305-2-tomeu.vizoso@collabora.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170102125912.22305-1-tomeu.vizoso@collabora.com> References: <20170102125912.22305-1-tomeu.vizoso@collabora.com> Cc: Tomeu Vizoso , Emil Velikov , dri-devel@lists.freedesktop.org, 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" There's no reason any more for callers of this function to take the lock themselves, so just move the lock to the function to avoid confusion and bugs when more callers are contributed. Signed-off-by: Tomeu Vizoso Reviewed-by: Emil Velikov Reviewed-by: Robert Foss --- drivers/gpu/drm/drm_debugfs_crc.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_debugfs_crc.c b/drivers/gpu/drm/drm_debugfs_crc.c index 00e771fb7df2..68b171af237b 100644 --- a/drivers/gpu/drm/drm_debugfs_crc.c +++ b/drivers/gpu/drm/drm_debugfs_crc.c @@ -325,16 +325,19 @@ int drm_crtc_add_crc_entry(struct drm_crtc *crtc, bool has_frame, struct drm_crtc_crc_entry *entry; int head, tail; - assert_spin_locked(&crc->lock); + spin_lock(&crc->lock); /* Caller may not have noticed yet that userspace has stopped reading */ - if (!crc->opened) + if (!crc->opened) { + spin_unlock(&crc->lock); return -EINVAL; + } head = crc->head; tail = crc->tail; if (CIRC_SPACE(head, tail, DRM_CRC_ENTRIES_NR) < 1) { + spin_unlock(&crc->lock); DRM_ERROR("Overflow of CRC buffer, userspace reads too slow.\n"); return -ENOBUFS; } @@ -347,6 +350,8 @@ 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); + return 0; } EXPORT_SYMBOL_GPL(drm_crtc_add_crc_entry);