From patchwork Mon Oct 24 11:29:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8675 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp422125wru; Mon, 24 Oct 2022 05:21:56 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6Crr7VO+SoC2qoiMnuDkbkFj6Ilf0fWOpNDnJYOrfp+ZFEcWqQznbAw9/FfttVaJZBr2Fs X-Received: by 2002:a17:907:9493:b0:796:1166:70c4 with SMTP id dm19-20020a170907949300b00796116670c4mr20813421ejc.59.1666614116174; Mon, 24 Oct 2022 05:21:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666614116; cv=none; d=google.com; s=arc-20160816; b=ufQMq1NvhjkToL/yZARiBmKUCFO0hejGNcFp92FiuIrb6Z0mm7Vr4Fw2H12bkSFGVh uR8oGL+3vUt4FVessI6FY7+hem/4yB+8aZtsxIACYN2i1EZVMddKzpRwkRhdN45N6lqX WWW2Jg5j/w9eWe37m1aOYYsDGbAACVg9nFFZZczUzeyZmyf8XqguHGxIMqe8x7SGN43o vqU4zRd7L1R6/rlpC/XRGRpuVY2CWjYnFGpOTyD/l+U/32vj+21ZiG2Kj2IYE2WIfFzb iUrxINIuPN3hoM6G96jJlCIE8vS+cOgEW916cZ54ew9VNw9Sz0q/uO/VFH5RPk76sIXJ Epuw== 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=oj9+aChjkZ+xk+1I2xUyqkhyvyuTGQKOcYgAOs/C35U=; b=j4a7SnI0iozpCDG08bxekbGfld4t6xpTq/RKqdB8NmY2DE9zEjkCGzQ/g99ZpdcuL4 zUCW2TdMSwo+LnfwmoXEjQdcWNlZ5NR9r4BYNa30gOfYWDEK5bjqgyFMIS8MIMzNJwjk shB6o4a5D6NLaKvTXqt9IDDAtXAheE4Ny4MbJrscxF1fVg6QGrXaiyWK9+IPcRK+xBDj MqBt5KlCSuugUQ7N3Vz+hIwmXn+je+PG+YTmDID6VYGeMgy55WBymWeCIbc+lFaCLzhd 1lltmTeLCVNySQXA0odsaxiuC1V/WtWaxcjTuzsjs3D8gLteCmlDLucKmHlYSfmCEjz6 TrAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QGdnJzN2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hs41-20020a1709073ea900b0077b6ecac099si28348777ejc.287.2022.10.24.05.21.32; Mon, 24 Oct 2022 05:21:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QGdnJzN2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S231294AbiJXMSO (ORCPT + 99 others); Mon, 24 Oct 2022 08:18:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233108AbiJXMQS (ORCPT ); Mon, 24 Oct 2022 08:16:18 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51F6A7AC36; Mon, 24 Oct 2022 04:56:38 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A802C612D3; Mon, 24 Oct 2022 11:56:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B9254C433D6; Mon, 24 Oct 2022 11:56:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666612598; bh=t+BBSIhts49B2P3FN9Z48QUqlQMj20aVsD3IeoAmpEQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QGdnJzN2VxvAPRXu+cc8W7PUebo+W5L3mvQTtjvJn7qHp5a/2XiRoukl7hGmaWxEx iZQfCZ3ovOdCjC6z7dy5FrPjWaPkhPhMOGTvULvz6RWJuyNlc7e7a5zTcYs6Bo+gom TOLmDcLZwgeqfyNFQmNOfAMY4VxCBXfQxlI6c7AU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andri Yngvason , Benjamin Tissoires Subject: [PATCH 4.19 046/229] HID: multitouch: Add memory barriers Date: Mon, 24 Oct 2022 13:29:25 +0200 Message-Id: <20221024113000.581586783@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112959.085534368@linuxfoundation.org> References: <20221024112959.085534368@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747571563216668951?= X-GMAIL-MSGID: =?utf-8?q?1747571563216668951?= From: Andri Yngvason commit be6e2b5734a425941fcdcdbd2a9337be498ce2cf upstream. This fixes broken atomic checks which cause a race between the release-timer and processing of hid input. I noticed that contacts were sometimes sticking, even with the "sticky fingers" quirk enabled. This fixes that problem. Cc: stable@vger.kernel.org Fixes: 9609827458c3 ("HID: multitouch: optimize the sticky fingers timer") Signed-off-by: Andri Yngvason Signed-off-by: Benjamin Tissoires Link: https://lore.kernel.org/r/20220907150159.2285460-1-andri@yngvason.is Signed-off-by: Greg Kroah-Hartman --- drivers/hid/hid-multitouch.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/drivers/hid/hid-multitouch.c +++ b/drivers/hid/hid-multitouch.c @@ -1154,7 +1154,7 @@ static void mt_touch_report(struct hid_d int contact_count = -1; /* sticky fingers release in progress, abort */ - if (test_and_set_bit(MT_IO_FLAGS_RUNNING, &td->mt_io_flags)) + if (test_and_set_bit_lock(MT_IO_FLAGS_RUNNING, &td->mt_io_flags)) return; scantime = *app->scantime; @@ -1235,7 +1235,7 @@ static void mt_touch_report(struct hid_d del_timer(&td->release_timer); } - clear_bit(MT_IO_FLAGS_RUNNING, &td->mt_io_flags); + clear_bit_unlock(MT_IO_FLAGS_RUNNING, &td->mt_io_flags); } static int mt_touch_input_configured(struct hid_device *hdev, @@ -1672,11 +1672,11 @@ static void mt_expired_timeout(struct ti * An input report came in just before we release the sticky fingers, * it will take care of the sticky fingers. */ - if (test_and_set_bit(MT_IO_FLAGS_RUNNING, &td->mt_io_flags)) + if (test_and_set_bit_lock(MT_IO_FLAGS_RUNNING, &td->mt_io_flags)) return; if (test_bit(MT_IO_FLAGS_PENDING_SLOTS, &td->mt_io_flags)) mt_release_contacts(hdev); - clear_bit(MT_IO_FLAGS_RUNNING, &td->mt_io_flags); + clear_bit_unlock(MT_IO_FLAGS_RUNNING, &td->mt_io_flags); } static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id)