Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp10608417rwr; Fri, 12 May 2023 10:16:12 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4gL02kuL7QcvviaoN1QkNZOzEGe8+oSbeSWsI17YoSMx8EiUkO+bdr8QX0EBx6gvjoQVOt X-Received: by 2002:a17:90a:ac15:b0:24e:44d1:18fd with SMTP id o21-20020a17090aac1500b0024e44d118fdmr24183780pjq.7.1683911771893; Fri, 12 May 2023 10:16:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683911771; cv=none; d=google.com; s=arc-20160816; b=hhRs44/CcoXZUaJ9bRxQhOJpklUvzzZIE8/zaLagQSHP/XjKPLsoUWcQiaPHW2o5Qe B7tYNcjeBe6uC8HS1nnciTQmSYtf2kvKyqcNbSqWTl1Ue2mMlNzdb58Eetw8iFu4DfVF 6CyuDYVAdMH3QnKRr1FpkThfqML982DTJJ4O2THC0p7XH27eLskjlL/NoEItGAJMapKJ 86ocevDslDDGIB+Gp3J6CwyAiTRF6Tj66iPpmYPGWAIfbOlAWPQrNpCBNp8s+oLiVZaB ygnKBtvr1CXMgAqShWLNjQdbYY5mpeaMtDIZSfcKIpoNUa3LxO4YOSN8qY4jNGhA6ewT AjXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=IVTgoVGLmfiSnDYvanbFiLjHDZAEOgfT7L1XJHgPDs4=; b=lEzwK9ThcN3HnlW0CPMa0Aus+7YmF1sYlKjXUiCSDiOGlJtvFLZOA282DdfaYwIJ18 ik/Laep18UHB0K8/V2B0ZgsDuRq1kU2qoS7N55o0OymbJXvJ1+coRyabVMrcQ2wG+izh xCxvC6POZiU/zZRrI21HIQspY4owCoVmq9DsoJOPvsym6mdnVWhtfJIuzRduyKHH8wRS cWopG2/sawo4vFK8505JBdLUSIwt7R2Oh04mYZ4RlXIxtvX2YBu5YIYnmqdYurMHCA39 iJ5mzhOHlPLCEcH0oj/3hfWcuwHFj0oiLhXgRMl8qwJMqBQqNZaj1LYMivnvISPm0s5L HxOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=Yy2XpG9W; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p18-20020a17090ad31200b00246b1a9630csi23169814pju.130.2023.05.12.10.15.59; Fri, 12 May 2023 10:16:11 -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=@gmail.com header.s=20221208 header.b=Yy2XpG9W; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237564AbjELQza (ORCPT + 99 others); Fri, 12 May 2023 12:55:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232659AbjELQz3 (ORCPT ); Fri, 12 May 2023 12:55:29 -0400 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0DB54C3D; Fri, 12 May 2023 09:55:21 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-3f427118644so60437795e9.0; Fri, 12 May 2023 09:55:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683910520; x=1686502520; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=IVTgoVGLmfiSnDYvanbFiLjHDZAEOgfT7L1XJHgPDs4=; b=Yy2XpG9W+CgUdhqpRnqt8p7ojoszi7SHmsuXn84K2qqr6Kgeqd8FJDMONlvMHiIROg 42MibeR0AYOtv/dB1jEVlmpiaczW+ZZ87VmxR/UXZW32x0vof3jQtA9Mo8ZKZpvIUvA9 a20w2j6El4yk8q0q39WxvUvKbrzAA9nQbrSB692jaFoGeOnJZuIzLPGj9bYQXwVbFbbT FpajdDAQpUOeysQbSgmovY+srcMZeKj6s5lEkhqEz18kKYMiBWzuzfMTyu05UZhv2YDG noL8f3cyDUPoqffypu5n7mc3/jJ9iaBHwogPqClLitQ7SPbnPPzt6eYHhSocXpzBTGR7 5cnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683910520; x=1686502520; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IVTgoVGLmfiSnDYvanbFiLjHDZAEOgfT7L1XJHgPDs4=; b=jZ+Xb8p9I/QA851LI07YrKOFl78kZ0cdb+OQMpOT6uMPvZd5wFf/BKA3E3hlUeTQJs nHdHxAJelYNRT7jgdPu3RpVy44Al5QDo/etWoiA9MUgGTJnGGu748ELnZYgXphO+9709 oalIcxxL5YZ8myEyaJoeM8w4uWPa5srAJZLBGPeQODkGYBCHKn1hdb+fxGa3wlHz+5Eu 029xFh4+wzuJfnJRseq0n+VXPk8A+r54dsr9Wd51a/PTsVMKTAUZ7xJ/tWEeGT9mNxCp coZ5AslelUnpRgaL2+b6SqG30tsFFmVNn1QcLgu/Fq1F0tzhGAPTN8DEM37JtBkKR/ZF rwRQ== X-Gm-Message-State: AC+VfDy2AAvrUKJ3G7n/RCWbxN0noFc7jmddUHm7vQNlca42wePfwkP2 zkoOQM9NOxhyMgXoAN8UsWGlSLnJUROZ6c+7kA== X-Received: by 2002:a1c:cc0e:0:b0:3ef:622c:26d3 with SMTP id h14-20020a1ccc0e000000b003ef622c26d3mr20385705wmb.35.1683910520000; Fri, 12 May 2023 09:55:20 -0700 (PDT) MIME-Version: 1.0 References: <20230503153231.1136114-1-tomas.mudrunka@gmail.com> In-Reply-To: From: =?UTF-8?B?VG9tw6HFoSBNdWRydcWIa2E=?= Date: Fri, 12 May 2023 18:55:08 +0200 Message-ID: Subject: Re: [PATCH v5] Fix freeze in lm8333 i2c keyboard driver To: Dmitry Torokhov Cc: Jeff LaBundy , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 > So this is still racy, isn't it? The interrupt may come after read is > done, but before we register the handler. Well. It is. But please see the rest of the thread, where we've already discussed this. Every time the interrupt handler runs, the interrupt is disabled and then reenabled after i2c communication is done. Which means this exact thing happens on each keypress anyway. So i don't think it's a necessarily huge deal. It might not be perfect solution, but it makes things much better. window in which the deadlock condition can happen is now in range of few ms (or us), instead of ~10 seconds (previously it included bootloader and basicaly any moment from power up to driver load) Another solution would be to trigger on LOW instead of FALLING as proposed in initial version of the patch. That would be safer in terms of lm8333 deadlock, but Jeff was concerned about possibility of interrupt storm taking down whole system in case the IRQ line gets stuck in LOW for some reason... Tom p=C3=A1 12. 5. 2023 v 1:44 odes=C3=ADlatel Dmitry Torokhov napsal: > > On Wed, May 03, 2023 at 08:44:06PM -0500, Jeff LaBundy wrote: > > Hi Tomas, > > > > On Wed, May 03, 2023 at 05:32:31PM +0200, Tomas Mudrunka wrote: > > > LM8333 uses gpio interrupt line which is triggered by falling edge. > > > When button is pressed before driver is loaded, > > > driver will miss the edge and never respond again. > > > To fix this we run the interrupt handler before registering IRQ > > > to clear the interrupt via i2c command. > > > > > > Signed-off-by: Tomas Mudrunka > > > --- > > > > Reviewed-by: Jeff LaBundy > > > > > drivers/input/keyboard/lm8333.c | 2 ++ > > > 1 file changed, 2 insertions(+) > > > > > > diff --git a/drivers/input/keyboard/lm8333.c b/drivers/input/keyboard= /lm8333.c > > > index 7457c3220..52108c370 100644 > > > --- a/drivers/input/keyboard/lm8333.c > > > +++ b/drivers/input/keyboard/lm8333.c > > > @@ -178,6 +178,8 @@ static int lm8333_probe(struct i2c_client *client= ) > > > dev_warn(&client->dev, "Unable to set active time= \n"); > > > } > > > > > > + lm8333_irq_thread(client->irq, lm8333); > > So this is still racy, isn't it? The interrupt may come after read is > done, but before we register the handler. > > > > + > > > err =3D request_threaded_irq(client->irq, NULL, lm8333_irq_thread= , > > > IRQF_TRIGGER_FALLING | IRQF_ONESHOT, > > > "lm8333", lm8333); > > > -- > > > 2.40.1 > > > > Thanks. > > -- > Dmitry