From patchwork Tue Feb 27 21:15:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?TWljaGHFgiBLxJlwaWXFhA==?= X-Patchwork-Id: 10246067 X-Patchwork-Delegate: dvhart@infradead.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9AA0F60362 for ; Tue, 27 Feb 2018 21:16:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8D7C728A9C for ; Tue, 27 Feb 2018 21:16:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 81BE628AB6; Tue, 27 Feb 2018 21:16:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 64AAD28A9C for ; Tue, 27 Feb 2018 21:16:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752057AbeB0VP4 (ORCPT ); Tue, 27 Feb 2018 16:15:56 -0500 Received: from mail-lf0-f68.google.com ([209.85.215.68]:36196 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752045AbeB0VPz (ORCPT ); Tue, 27 Feb 2018 16:15:55 -0500 Received: by mail-lf0-f68.google.com with SMTP id g72so381591lfg.3 for ; Tue, 27 Feb 2018 13:15:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kempniu.pl; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SMJeAIlsHGD4nB0IKFMEDutU/z4wXi9HS1yyhvFQfhw=; b=Vn0/+4x/aREs/uZUPnjtBLfFhVZK9UpjOzoQnhgil7wbBsCbQ71dKspMm3kkCyN8ZE 25mpcbhT28J5DG6VLKTe8mr9wEKGNmzMg7KhX2YWc0hZf5+RAxpjWBNG38IPVMTjmJIh Qb9iyouPau6znw+F6lTByaGpzesf4h7JaAZi0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SMJeAIlsHGD4nB0IKFMEDutU/z4wXi9HS1yyhvFQfhw=; b=HQjvsvpYc1Vn8tmWSamhf7ojfavTsi/i9rXcY/AlBz10XMbN0QobuecuaICFuM9ozm zXgpAmbpG/kPBLMVcjEZtTeqzqvviXlNaC0jRST+pWe4Di+GJJyqN2bT9+DGa/zaK13P tCPuUEnShiMoFodKamwoXPiSFjNYtPAoKeHzjys8h2mKddiAFnFMtitf6JPrGEijfYsy FY+jrkrri2gQaVjXtOBht0zIXw4/Ksnezzk3okqXzYUflmEJQsMFOgVwjbNRoEkQBzQs sVXdtUPZnBSSyH0s37eMT3adewdQKZMOQzD6jifbiUg8/ob8l6+ajjPiBZFGrpMBe7tt nesA== X-Gm-Message-State: APf1xPA699ZGbmIQW7tg5DvXYa7wIWOkI62BL6MR2VaUcHYAtD03A8MC PRrrgmsDYq61O/Wn2owKMMSYjg== X-Google-Smtp-Source: AG47ELv6exkn6Wqx8We1pU2FscSgMKgXRkMdwB9TFLnaU+VhphVvQzOCyonzM681JhT/3OcgHe88aw== X-Received: by 10.46.83.87 with SMTP id t23mr10658037ljd.38.1519766153599; Tue, 27 Feb 2018 13:15:53 -0800 (PST) Received: from kmp-mobile.hq.kempniu.pl (kmp-mobile.hq.kempniu.pl. [2001:470:64df:111::d0d7]) by smtp.googlemail.com with ESMTPSA id l5sm16288lje.58.2018.02.27.13.15.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Feb 2018 13:15:52 -0800 (PST) From: =?UTF-8?q?Micha=C5=82=20K=C4=99pie=C5=84?= To: Jonathan Woithe , Darren Hart , Andy Shevchenko Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 6/7] platform/x86: fujitsu-laptop: More accurately represent the hotkey ring buffer managed by firmware Date: Tue, 27 Feb 2018 22:15:38 +0100 Message-Id: <20180227211539.5708-7-kernel@kempniu.pl> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180227211539.5708-1-kernel@kempniu.pl> References: <20180227211539.5708-1-kernel@kempniu.pl> MIME-Version: 1.0 Sender: platform-driver-x86-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The MAX_HOTKEY_RINGBUFFER_SIZE constant is set to 100, which allows up to 100 hotkey events to be drained from the firmware ring buffer upon module load. However, no known firmware is capable of holding more than 16 hotkey events in its internal ring buffer: Method (SIRB, 1, NotSerialized) { If ((BNCT < 0x10)) { CreateWordField (BNBF, BNSP, BNP1) BNP1 = Arg0 BNCT++ BNSP += 0x02 If ((BNSP >= 0x20)) { BNSP = Zero } } } The RINGBUFFERSIZE constant is set to 40, which allows the module to queue up to 40 hotkey events for delivery to user space. As this value seems arbitrarily chosen and 16 should be more than enough for any practical use case, merge the two aforementioned constants into one (HOTKEY_RINGBUFFER_SIZE) in order to simplify code and more accurately represent the underlying data structure. Signed-off-by: Michał Kępień --- drivers/platform/x86/fujitsu-laptop.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c index 5acf1ccc6864..46c9f4441c24 100644 --- a/drivers/platform/x86/fujitsu-laptop.c +++ b/drivers/platform/x86/fujitsu-laptop.c @@ -107,8 +107,7 @@ #define EVENT_HK4 0x413 #define EVENT_HK5 0x420 -#define MAX_HOTKEY_RINGBUFFER_SIZE 100 -#define RINGBUFFERSIZE 40 +#define HOTKEY_RINGBUFFER_SIZE 16 /* Constant related to FUNC_FLAGS */ #define FLAG_DOCK BIT(9) @@ -815,7 +814,7 @@ static int acpi_fujitsu_laptop_add(struct acpi_device *device) /* kfifo */ spin_lock_init(&priv->fifo_lock); - ret = kfifo_alloc(&priv->fifo, RINGBUFFERSIZE * sizeof(int), + ret = kfifo_alloc(&priv->fifo, HOTKEY_RINGBUFFER_SIZE * sizeof(int), GFP_KERNEL); if (ret) return ret; @@ -825,7 +824,7 @@ static int acpi_fujitsu_laptop_add(struct acpi_device *device) while (call_fext_func(device, FUNC_BUTTONS, OP_GET_EVENTS, 0x0, 0x0) != 0 && - i++ < MAX_HOTKEY_RINGBUFFER_SIZE) + i++ < HOTKEY_RINGBUFFER_SIZE) ; /* No action, result is discarded */ acpi_handle_debug(device->handle, "Discarded %i ringbuffer entries\n", i); @@ -941,7 +940,7 @@ static void acpi_fujitsu_laptop_notify(struct acpi_device *device, u32 event) while ((irb = call_fext_func(device, FUNC_BUTTONS, OP_GET_EVENTS, 0x0, 0x0)) != 0 && - i++ < MAX_HOTKEY_RINGBUFFER_SIZE) { + i++ < HOTKEY_RINGBUFFER_SIZE) { scancode = irb & 0x4ff; if (sparse_keymap_entry_from_scancode(priv->input, scancode)) acpi_fujitsu_laptop_press(device, scancode);