From patchwork Wed Mar 23 01:04:03 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Brown X-Patchwork-Id: 653971 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p2N15OvW014178 for ; Wed, 23 Mar 2011 01:05:24 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754101Ab1CWBFG (ORCPT ); Tue, 22 Mar 2011 21:05:06 -0400 Received: from mail-iy0-f174.google.com ([209.85.210.174]:59781 "EHLO mail-iy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753202Ab1CWBET (ORCPT ); Tue, 22 Mar 2011 21:04:19 -0400 Received: by mail-iy0-f174.google.com with SMTP id 26so8031243iyb.19 for ; Tue, 22 Mar 2011 18:04:18 -0700 (PDT) Received: by 10.42.76.71 with SMTP id d7mr5785106ick.109.1300842258744; Tue, 22 Mar 2011 18:04:18 -0700 (PDT) Received: from localhost.localdomain (daedalus.mtv.corp.google.com [172.18.103.24]) by mx.google.com with ESMTPS id i2sm4933510icv.15.2011.03.22.18.04.17 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 22 Mar 2011 18:04:18 -0700 (PDT) From: Jeff Brown To: linux-input@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Jeff Brown , jeffbrown@android.com Subject: [PATCH 3/4] input: evdev: Indicate buffer overrun with SYN_DROPPED. Date: Tue, 22 Mar 2011 18:04:03 -0700 Message-Id: <1300842244-42723-4-git-send-email-jeffbrown@android.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1300842244-42723-1-git-send-email-jeffbrown@android.com> References: <1300842244-42723-1-git-send-email-jeffbrown@android.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Wed, 23 Mar 2011 01:05:24 +0000 (UTC) diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c index 7f42d3a..203ed70 100644 --- a/drivers/input/evdev.c +++ b/drivers/input/evdev.c @@ -57,14 +57,20 @@ static void evdev_pass_event(struct evdev_client *client, { /* * Interrupts are disabled, just acquire the lock. - * Make sure we don't leave with the client buffer - * "empty" by having client->head == client->tail. + * When the client buffer is full, replace the tail with SYN_DROPPED + * to let the client know that events were dropped. Ensure that the + * head and tail never coincide so the buffer does not appear "empty". */ spin_lock(&client->buffer_lock); - do { - client->buffer[client->head++] = *event; - client->head &= client->bufsize - 1; - } while (client->head == client->tail); + client->buffer[client->head++] = *event; + client->head &= client->bufsize - 1; + if (client->head == client->tail) { + client->tail = (client->tail + 1) & (client->bufsize - 1); + client->buffer[client->tail].time = event->time; + client->buffer[client->tail].type = EV_SYN; + client->buffer[client->tail].code = SYN_DROPPED; + client->buffer[client->tail].value = 0; + } spin_unlock(&client->buffer_lock); if (event->type == EV_SYN) diff --git a/include/linux/input.h b/include/linux/input.h index 056ae8a..65d253e 100644 --- a/include/linux/input.h +++ b/include/linux/input.h @@ -167,6 +167,7 @@ struct input_keymap_entry { #define SYN_REPORT 0 #define SYN_CONFIG 1 #define SYN_MT_REPORT 2 +#define SYN_DROPPED 3 /* * Keys and buttons