Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp103651pxx; Tue, 27 Oct 2020 22:57:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxqeNjaGOBML/U5XiS+MXvW79wc2uVomxKD8hAQbf7Pjc/epDQ1C7kJiZQfWc/wVS20gWHY X-Received: by 2002:a17:906:b110:: with SMTP id u16mr5919586ejy.55.1603864644701; Tue, 27 Oct 2020 22:57:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603864644; cv=none; d=google.com; s=arc-20160816; b=nUYXdAM2jRCAqhJ0ylu9WQdvf+9zxGacRr+2qTJGv3hpkGQp6EM1AOXAskXMIsk6Ce dfXrQBLkEfleBEyH3/iXoBtOv3+2gFts9dHPYZ5O1R2f8oMQNg71x40iIkI8jYRvxO+x /SC9zOQIAqzAzgiL/lAEwJXqZmhzBDD8vyweAAuJazW7oXKkxDJBNUcPSJG4snAUkkLx W1Wm1lkiV94Ws0M/9dbplaZ7dUO/SSlDfVst1Ewqr3PJ06SCWrnXD4ERTIXeHpqssvCO 37+Zj+xM4Z/kv2pnU0w8jZhX5gDncvZ6o/ZdWw7GrS4mZyRaVMwq+I1f5ZjMfViJHy8u cswA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=GZZ58+ZVOppvmT10OUfK4ncfMaLBev9txt8gD6bLxtw=; b=zYZOPg7rkDjiYx6BCJUAdb2isWH+71PYhb19frU1PQ2FsuV/OYxVPrETJhmV4zolKQ xiIGVwq8p19XT5s0mcHvI/rYgHwPKD0Ds3HI7pziwNNjjUekqOWGoC5lYi35+aqrdFNk 70LhsZ/82O+8CAA9R9cNe6OBoqzxzH+AjJtkupBAg9afBtWuRDregDr1Pw5u+4e19gW7 xoDQIF3GogrC2EL7g8MZv9JLvqVdkuBtbwgxMXVfz5GkI57kvAbP0sjrZTMnzxo0iOHJ zAaLrhkNZKOvkpBRcsew7uNf/8D/qVAwF0ihC+mH02yEChg+T1fjFWt2Nwco5C888wX0 duOA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d12si2594068ejt.9.2020.10.27.22.57.01; Tue, 27 Oct 2020 22:57:24 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2509230AbgJ0IpH (ORCPT + 99 others); Tue, 27 Oct 2020 04:45:07 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:48239 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2509219AbgJ0IpG (ORCPT ); Tue, 27 Oct 2020 04:45:06 -0400 Received: from pty.hi.pengutronix.de ([2001:67c:670:100:1d::c5]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kXKbG-0003rX-Cj; Tue, 27 Oct 2020 09:45:02 +0100 Received: from ore by pty.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1kXKbF-0008T3-3v; Tue, 27 Oct 2020 09:45:01 +0100 Date: Tue, 27 Oct 2020 09:45:01 +0100 From: Oleksij Rempel To: Dmitry Torokhov Cc: Alexandru Ardelean , David Jander , kernel@pengutronix.de, linux-kernel@vger.kernel.org, linux-input@vger.kernel.org Subject: Re: [PATCH v1] Input: touchscreen: ads7846.c: Fix race that causes missing releases Message-ID: <20201027084501.rjfza4il5gv7ursy@pengutronix.de> References: <20201026132117.20887-1-o.rempel@pengutronix.de> <20201027034851.GH444962@dtor-ws> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20201027034851.GH444962@dtor-ws> X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-IRC: #ptxdist @freenode X-Accept-Language: de,en X-Accept-Content-Type: text/plain X-Uptime: 09:07:38 up 346 days, 23:26, 374 users, load average: 0.11, 0.05, 0.01 User-Agent: NeoMutt/20170113 (1.7.2) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c5 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 26, 2020 at 08:48:51PM -0700, Dmitry Torokhov wrote: > Hi Oleksij, > > On Mon, Oct 26, 2020 at 02:21:17PM +0100, Oleksij Rempel wrote: > > From: David Jander > > > > If touchscreen is released while busy reading HWMON device, the release > > can be missed. The IRQ thread is not started because no touch is active > > and BTN_TOUCH release event is never sent. > > > > Fixes: f5a28a7d4858f94a ("Input: ads7846 - avoid pen up/down when reading hwmon") > > Co-Developed-by: David Jander > > Signed-off-by: David Jander > > Signed-off-by: Oleksij Rempel > > --- > > drivers/input/touchscreen/ads7846.c | 16 ++++++++++++++++ > > 1 file changed, 16 insertions(+) > > > > diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c > > index ea31956f3a90..0236a119c52d 100644 > > --- a/drivers/input/touchscreen/ads7846.c > > +++ b/drivers/input/touchscreen/ads7846.c > > @@ -211,10 +211,26 @@ static void ads7846_stop(struct ads7846 *ts) > > } > > } > > > > +static int get_pendown_state(struct ads7846 *ts); > > Not a fan forward declarations, just move the definition if needed. ok > > + > > /* Must be called with ts->lock held */ > > static void ads7846_restart(struct ads7846 *ts) > > { > > + unsigned int pdstate; > > I do not see it being used. Do you have more patches for the driver? Ooops. Artifact of previous version of this patch. But, yes, there is one huge patch with major rework of this driver. I'll need to split it before sending. Or, are you ready to accept a one big patch? :) > > + > > if (!ts->disabled && !ts->suspended) { > > + /* Check if pen was released since last stop */ > > + if (ts->pendown && !get_pendown_state(ts)) { > > + struct input_dev *input = ts->input; > > + > > + input_report_key(input, BTN_TOUCH, 0); > > + input_report_abs(input, ABS_PRESSURE, 0); > > + input_sync(input); > > + > > + ts->pendown = false; > > + dev_vdbg(&ts->spi->dev, "UP\n"); > > I wonder if we should not have ads7846_report_pen_up(struct ads7846 *ts) Sure, which is already done in rework patch. Should I move this change here? > > + } > > + > > /* Tell IRQ thread that it may poll the device. */ > > ts->stopped = false; > > mb(); > > -- > > 2.28.0 > > > Regards, Oleksij -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |