Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp3983003pxb; Mon, 4 Oct 2021 14:23:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyBbMCVBEwNn2A9ZFCtQg2pPNqeYYVZ1xSetblbbhtu6kMr0zczxPQD1nZtB03AQuJz2IVn X-Received: by 2002:a17:902:c406:b0:13b:7b40:9c5a with SMTP id k6-20020a170902c40600b0013b7b409c5amr1709484plk.81.1633382614983; Mon, 04 Oct 2021 14:23:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633382614; cv=none; d=google.com; s=arc-20160816; b=IkwmeOQsKc7oCwe0ae3mdu/mHv9wkW1B21bQrzxQlDdwk1gaOOjarTK6mgg9QwthVq w6eCvFQo3OLKqHe4yRVGQa/5Ze3/blIjI/0wL+jcCovFvLg5XUKRQYJ6xtt/v+ls4Opw 8Dy3NDj0bpTkblC0R1MAxZgAJbmHIeWBAi6AbDNh0IvBpidpJlScGAbCeJ+mWIyrcqx2 IXnjAmkMNjMTA/xUy5Zx3ftNSD8Vcnj+D1yT7c1VFWWEGDCCVZhQtdLBa6/6DGDSx2T/ rTcddD7Xd6g2rrCxr6QvQKJQ6yZp0+NetrJS8A0U1FHS8aC34lMWIy6qu/3VfChhXEWf nPQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=V0JZWOhukI1Snu82kpmFG5KkOGIzEJgEDOjSJo2b9n4=; b=fOH8MAmI6y+F8oI9jRZAmcqaBYXHqH6pyds3eVvmA3jYVjFj0J5o7GVB5lob/10pZe 6tRKPKhdgn6nn1fMvZPyIvyJLIB9W8TX5xNlxgTtXeYJ1SDeaWML4k9Tz6BAqGLqIdTo 7R5rioKk7wk/FK0dldHWY38Cl1azkpAhmFIt9czP8wTlpXcIsuI1XER2wPZmj8dubTNZ Q7Gn8hQx39BNYN2DS8OGt4IDJz4N0rd5w1tTqD/jw5ZLa/fYjICU0qBU5aA6/7oAJlMJ rkBa0zuTL8gXbsE87AUZvXPGJ3nQOMfCnFoK4I9KElfVrogQCn28aB5WcScPZGjobYrQ 9Fjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=SHqJTP5v; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t5si3844476pfh.90.2021.10.04.14.23.22; Mon, 04 Oct 2021 14:23:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=SHqJTP5v; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237532AbhJDNch (ORCPT + 99 others); Mon, 4 Oct 2021 09:32:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:43772 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237779AbhJDNae (ORCPT ); Mon, 4 Oct 2021 09:30:34 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 45B2B61B98; Mon, 4 Oct 2021 13:13:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1633353233; bh=2iwA1Qy+a765qThMzGVroZ6eJPLsSgRAlizBSs5Cjn4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SHqJTP5vdzL50RhXGMKR9/FAE3+k/3gYWt26c3Z3mRpX/EPjq+6Kn/rGNHoTVlHPV UHI+AWTyA7eiH9Zx9fEsGZ7TnZh5lKLlRUEgl5FFQbqgpY7NToIqOUu9g6oZGgdrqX 6GCOHvRVEo2uaU+xnh29X2uad9Up0SeQH1fE5hU0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tobias Gurtzick , Hans de Goede , =?UTF-8?q?Jos=C3=A9=20Exp=C3=B3sito?= Subject: [PATCH 5.14 047/172] platform/x86/intel: hid: Add DMI switches allow list Date: Mon, 4 Oct 2021 14:51:37 +0200 Message-Id: <20211004125046.509981455@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211004125044.945314266@linuxfoundation.org> References: <20211004125044.945314266@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: José Expósito commit b201cb0ebe87b209e252d85668e517ac1929e250 upstream. Some devices, even non convertible ones, can send incorrect SW_TABLET_MODE reports. Add an allow list and accept such reports only from devices in it. Bug reported for Dell XPS 17 9710 on: https://gitlab.freedesktop.org/libinput/libinput/-/issues/662 Reported-by: Tobias Gurtzick Suggested-by: Hans de Goede Tested-by: Tobias Gurtzick Signed-off-by: José Expósito Link: https://lore.kernel.org/r/20210920160312.9787-1-jose.exposito89@gmail.com [hdegoede@redhat.com: Check dmi_switches_auto_add_allow_list only once] Signed-off-by: Hans de Goede Signed-off-by: Greg Kroah-Hartman --- drivers/platform/x86/intel-hid.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) --- a/drivers/platform/x86/intel-hid.c +++ b/drivers/platform/x86/intel-hid.c @@ -118,12 +118,30 @@ static const struct dmi_system_id dmi_vg { } }; +/* + * Some devices, even non convertible ones, can send incorrect SW_TABLET_MODE + * reports. Accept such reports only from devices in this list. + */ +static const struct dmi_system_id dmi_auto_add_switch[] = { + { + .matches = { + DMI_EXACT_MATCH(DMI_CHASSIS_TYPE, "31" /* Convertible */), + }, + }, + { + .matches = { + DMI_EXACT_MATCH(DMI_CHASSIS_TYPE, "32" /* Detachable */), + }, + }, + {} /* Array terminator */ +}; + struct intel_hid_priv { struct input_dev *input_dev; struct input_dev *array; struct input_dev *switches; bool wakeup_mode; - bool dual_accel; + bool auto_add_switch; }; #define HID_EVENT_FILTER_UUID "eeec56b3-4442-408f-a792-4edd4d758054" @@ -452,10 +470,8 @@ static void notify_handler(acpi_handle h * Some convertible have unreliable VGBS return which could cause incorrect * SW_TABLET_MODE report, in these cases we enable support when receiving * the first event instead of during driver setup. - * - * See dual_accel_detect.h for more info on the dual_accel check. */ - if (!priv->switches && !priv->dual_accel && (event == 0xcc || event == 0xcd)) { + if (!priv->switches && priv->auto_add_switch && (event == 0xcc || event == 0xcd)) { dev_info(&device->dev, "switch event received, enable switches supports\n"); err = intel_hid_switches_setup(device); if (err) @@ -596,7 +612,8 @@ static int intel_hid_probe(struct platfo return -ENOMEM; dev_set_drvdata(&device->dev, priv); - priv->dual_accel = dual_accel_detect(); + /* See dual_accel_detect.h for more info on the dual_accel check. */ + priv->auto_add_switch = dmi_check_system(dmi_auto_add_switch) && !dual_accel_detect(); err = intel_hid_input_setup(device); if (err) {