From patchwork Tue Mar 31 09:43:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Echtler X-Patchwork-Id: 6128321 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9F4529F2EC for ; Tue, 31 Mar 2015 09:43:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CA50820165 for ; Tue, 31 Mar 2015 09:43:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 312CD201B4 for ; Tue, 31 Mar 2015 09:43:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752862AbbCaJnf (ORCPT ); Tue, 31 Mar 2015 05:43:35 -0400 Received: from butterbrot.org ([176.9.106.16]:50377 "EHLO butterbrot.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750962AbbCaJnf (ORCPT ); Tue, 31 Mar 2015 05:43:35 -0400 Received: from flunder.scc.uni-weimar.de (eduroam-051-199.scc.uni-weimar.de [141.54.51.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by butterbrot.org (Postfix) with ESMTPSA id C8A6C5C00784; Tue, 31 Mar 2015 11:43:33 +0200 (CEST) From: Florian Echtler To: hverkuil@xs4all.nl, m.chehab@samsung.com Cc: laurent.pinchart@ideasonboard.com, linux-input@vger.kernel.org, linux-media@vger.kernel.org, Florian Echtler Subject: [PATCH] sur40: fix occasional hard freeze due to buffer queue underrun Date: Tue, 31 Mar 2015 11:43:28 +0200 Message-Id: <1427795008-10385-1-git-send-email-floe@butterbrot.org> X-Mailer: git-send-email 1.9.1 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch fixes a kernel panic which occurs when buf_list is empty. This can happen occasionally when user space is under heavy load (e.g. due to image processing on the CPU) and new buffers aren't re-queued fast enough. In that case, vb2_start_streaming_called can return true, but when the spinlock is taken and sur40_poll attempts to fetch the next buffer from buf_list, the list is in fact empty. This patch needs to be applied on top of the queued one adding V4L2 support to the sur40 driver. Signed-off-by: Florian Echtler --- drivers/input/touchscreen/sur40.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/input/touchscreen/sur40.c b/drivers/input/touchscreen/sur40.c index 1e7dacf..d618514 100644 --- a/drivers/input/touchscreen/sur40.c +++ b/drivers/input/touchscreen/sur40.c @@ -380,6 +380,11 @@ static void sur40_process_video(struct sur40_state *sur40) /* get a new buffer from the list */ spin_lock(&sur40->qlock); + if (list_empty(&sur40->buf_list)) { + dev_dbg(sur40->dev, "buffer queue empty\n"); + spin_unlock(&sur40->qlock); + return; + } new_buf = list_entry(sur40->buf_list.next, struct sur40_buffer, list); list_del(&new_buf->list); spin_unlock(&sur40->qlock);