From patchwork Thu Oct 5 00:20:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeffery Miller X-Patchwork-Id: 13409685 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7B514E936EC for ; Thu, 5 Oct 2023 00:23:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244184AbjJEAXb (ORCPT ); Wed, 4 Oct 2023 20:23:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244152AbjJEAXb (ORCPT ); Wed, 4 Oct 2023 20:23:31 -0400 Received: from mail-ot1-x34a.google.com (mail-ot1-x34a.google.com [IPv6:2607:f8b0:4864:20::34a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7821D95 for ; Wed, 4 Oct 2023 17:23:27 -0700 (PDT) Received: by mail-ot1-x34a.google.com with SMTP id 46e09a7af769-6c65fe5e6f0so476801a34.3 for ; Wed, 04 Oct 2023 17:23:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1696465407; x=1697070207; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=uamWKvizGVLyWmbe/E5IO6qRkfMAehoyNPcply0ANnU=; b=2hUKNhbR9vKCCV5YuwK/SPNOsu2YRcTyH8sPQNSjvhsQnF4mhkPIeo+SFNTOrQf7ze vvMWjQ+UpF/YRgusTu2nIDkiwEqajZgH4HZCEWj8cTZnzxjCtHj70W9GmKnQIGkgDWk1 RP4etEfPvhKhfkuVkG5v/xUXdJ8frxEStnFVo7cZ21I9ihywsntJcOzHe7FZaemKKWGk 2njmA+8ubhaXX/0XV0vtsiqnWVBWQB8L/kGXly8LFhGbjZ1CnYC5I+jRYnL+E4mPD/i2 v4+srZX4DG1//ZnJ4nydf1XsGnEqBO3pWX6ghWoBQR7lbaegVayOZbkHAfViPcOhZPDf rSIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696465407; x=1697070207; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=uamWKvizGVLyWmbe/E5IO6qRkfMAehoyNPcply0ANnU=; b=pEIbSgLLIMO+EKcRi/8WoU2o2vu2c1IH+NUYEAa9vQhKHDzfx/HvXyNXGErootYneg TYSkx/GwXTYDlJKmA5VOgkaBTLe062FFYObVHSqF+HHdfaJSHoE18UYyFltXS7a7FXJT qunQ9EOB9HWbjWLfhzHAN4thlMhkPds3DSZa4HBYyEgpSA2j+d1XP+Va08titNTNgiW+ lOq8oEoL84pq6mAFjkcFQ+hrV8QlBHtOqr7uLP8yqXAszV2k4AbGaN2GYxvj1ychw9hs 2xSYun1u+IJyo1vuTNahgnPh5yjwaIOWoifDurqI1viqb5F/AK10mWTxHD57dJ6mUOza NjyQ== X-Gm-Message-State: AOJu0Yz+yz7CuyogjlXu8rBNQOpjOy/yte7vbFhgUTgT46C5RUoN4Eou b74jlEg/OBzZN6xjhfixfaXAbBjNyuog9BHzZOrE X-Google-Smtp-Source: AGHT+IGPTG6blfnNFLzCOFXwIz6xwDPRyA8tMfVvzBK24OalkQInaEHCeTFIYhQ1E7glzzbZnd/emD62BfZSvrMcAHMT X-Received: from horchata.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:5b3]) (user=jefferymiller job=sendgmr) by 2002:a05:6830:1114:b0:6c0:b1b2:9504 with SMTP id w20-20020a056830111400b006c0b1b29504mr1021192otq.3.1696465406857; Wed, 04 Oct 2023 17:23:26 -0700 (PDT) Date: Wed, 4 Oct 2023 19:20:20 -0500 Mime-Version: 1.0 X-Mailer: git-send-email 2.42.0.582.g8ccd20d70d-goog Message-ID: <20231005002249.554877-1-jefferymiller@google.com> Subject: [PATCH v2] Input: psmouse - fix fast_reconnect function for PS/2 mode From: Jeffery Miller To: Dmitry Torokhov Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, Andrew Duggan , Andrew Duggan , loic.poulain@linaro.org, linux@leemhuis.info, benjamin.tissoires@redhat.com, Jeffery Miller Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Make elantech_setup_ps2 and synaptics_init_ps2 set an appropriate fast_reconnect pointer when the PS/2 mode is used. When the SMBus connection is attempted psmouse_smbus_init sets the fast_reconnect pointer to psmouse_smbus_reconnect. When this fails elantech_setup_ps2 and synaptics_init_ps2 will fallback to PS/2 mode replacing the psmouse private data. This was causing an issue on resume since psmouse_smbus_reconnect was being called while in PS/2 mode and attempting to use the invalid private data. This issue was uncovered when psmouse_smbus_reconnect started attempting to use more of the data structure. Reported-by: Thorsten Leemhuis Closes: https://lore.kernel.org/all/ca0109fa-c64b-43c1-a651-75b294d750a1@leemhuis.info/ Fixes: 92e24e0e57f7 ("Input: psmouse - add delay when deactivating for SMBus mode") Tested-by: Thorsten Leemhuis Signed-off-by: Jeffery Miller --- The other callbacks set in psmouse_smbus_init are already replaced. Changes in v2: - Also set fast_reconnect in the synaptics ps2 fallback path from review comments. - Add Fixes: tag to the commit that uncovered the problem. drivers/input/mouse/elantech.c | 1 + drivers/input/mouse/synaptics.c | 1 + 2 files changed, 2 insertions(+) diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c index 2118b2075f43..4e38229404b4 100644 --- a/drivers/input/mouse/elantech.c +++ b/drivers/input/mouse/elantech.c @@ -2114,6 +2114,7 @@ static int elantech_setup_ps2(struct psmouse *psmouse, psmouse->protocol_handler = elantech_process_byte; psmouse->disconnect = elantech_disconnect; psmouse->reconnect = elantech_reconnect; + psmouse->fast_reconnect = NULL; psmouse->pktsize = info->hw_version > 1 ? 6 : 4; return 0; diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c index ada299ec5bba..cefc74b3b34b 100644 --- a/drivers/input/mouse/synaptics.c +++ b/drivers/input/mouse/synaptics.c @@ -1623,6 +1623,7 @@ static int synaptics_init_ps2(struct psmouse *psmouse, psmouse->set_rate = synaptics_set_rate; psmouse->disconnect = synaptics_disconnect; psmouse->reconnect = synaptics_reconnect; + psmouse->fast_reconnect = NULL; psmouse->cleanup = synaptics_reset; /* Synaptics can usually stay in sync without extra help */ psmouse->resync_time = 0;