From mboxrd@z Thu Jan 1 00:00:00 1970 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 69973C3F6B0 for ; Wed, 17 Aug 2022 17:03:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237953AbiHQRDA (ORCPT ); Wed, 17 Aug 2022 13:03:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237915AbiHQRDA (ORCPT ); Wed, 17 Aug 2022 13:03:00 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CF9D9BB40; Wed, 17 Aug 2022 10:02:59 -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 ams.source.kernel.org (Postfix) with ESMTPS id ED81BB81E43; Wed, 17 Aug 2022 17:02:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 58909C433D6; Wed, 17 Aug 2022 17:02:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660755776; bh=HlzVrPwIlIGzj2nu9TwVvh5tZSLO33lhBKPSWBotLeA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=SgwgMKTuoBp/XNMoiOCu5YUgy4S5M52HwT629mq+5UGrWUf75yeMTTqlBMXt0phH7 a/p8jYnHiaUJqK8yPzfOjs3X6HUSDdkYBUzpYJ7+rR5ioCieQEhfhb24pjjFjW47tu idvbnN9iSjeoRI7PrjfKBTt0l3iBU/Wm0nEcaKtU= Date: Wed, 17 Aug 2022 19:02:53 +0200 From: Greg KH To: Andri Yngvason Cc: Jiri Kosina , Benjamin Tissoires , linux-input@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH RESEND] HID: multitouch: Add memory barriers Message-ID: References: <20220817113247.3530979-1-andri@yngvason.is> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org On Wed, Aug 17, 2022 at 04:14:20PM +0000, Andri Yngvason wrote: > Hi Greg, > > miš., 17. įgś. 2022 kl. 11:59 skrifaši Greg KH : > > > > On Wed, Aug 17, 2022 at 11:32:48AM +0000, Andri Yngvason wrote: > > > This fixes a race with the release-timer by adding acquire/release > > > barrier semantics. > > > > What race? > > > > The race is between the release timer and processing of hid input. It > is quite certain that these atomic checks are broken as is because > they're lacking memory barriers and this patch does fix an actual > problem for me. Perhaps you should say that in this changelog then. > > I must admit that I don't know exactly where the execution reordering > occurs and I haven't checked the generated assembly code, but if you > look at e.g. mt_expired_timeout(), you'll see that there's nothing to > keep the compiler or CPU from hoisting the test_bit() call above the > test_and_set_bit() call. > > > > > > > I noticed that contacts were sometimes sticking, even with the "sticky > > > fingers" quirk enabled. This fixes that problem. > > > > > > Cc: stable@vger.kernel.org > > > Signed-off-by: Andri Yngvason > > > --- > > > drivers/hid/hid-multitouch.c | 8 ++++---- > > > 1 file changed, 4 insertions(+), 4 deletions(-) > > > > > > diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c > > > index 2e72922e36f5..91a4d3fc30e0 100644 > > > --- a/drivers/hid/hid-multitouch.c > > > +++ b/drivers/hid/hid-multitouch.c > > > @@ -1186,7 +1186,7 @@ static void mt_touch_report(struct hid_device *hid, > > > 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)) > > > > So this is now a lock? > > > > Why not just use a real lock instead? > > > > I don't know. This stuff was introduced in > 9609827458c37d7b2c37f2a9255631c603a5004c by Benjamin Tissoires. Then this needs a "Fixes:" tag? thanks, greg k-h