From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dmitry Torokhov Subject: Re: [PATCH v2] Input: atmel_mxt_ts - Disable IRQ across suspend Date: Fri, 27 Sep 2019 17:16:26 -0700 Message-ID: <20190928001626.GT237523@dtor-ws> References: <20190924215238.184750-1-evgreen@chromium.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <20190924215238.184750-1-evgreen@chromium.org> Sender: linux-kernel-owner@vger.kernel.org To: Evan Green Cc: Nick Dyer , Jongpil Jung , Furquan Shaikh , Rajat Jain , linux-kernel@vger.kernel.org, linux-input@vger.kernel.org List-Id: linux-input@vger.kernel.org Hi Evan, On Tue, Sep 24, 2019 at 02:52:38PM -0700, Evan Green wrote: > Across suspend and resume, we are seeing error messages like the following: > > atmel_mxt_ts i2c-PRP0001:00: __mxt_read_reg: i2c transfer failed (-121) > atmel_mxt_ts i2c-PRP0001:00: Failed to read T44 and T5 (-121) > > This occurs because the driver leaves its IRQ enabled. Upon resume, there > is an IRQ pending, but the interrupt is serviced before both the driver and > the underlying I2C bus have been resumed. This causes EREMOTEIO errors. > > Disable the IRQ in suspend, and re-enable it on resume. If there are cases > where the driver enters suspend with interrupts disabled, that's a bug we > should fix separately. > > Signed-off-by: Evan Green > --- > > Changes in v2: > - Enable and disable unconditionally (Dmitry) > > drivers/input/touchscreen/atmel_mxt_ts.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c > index 24c4b691b1c9..a58092488679 100644 > --- a/drivers/input/touchscreen/atmel_mxt_ts.c > +++ b/drivers/input/touchscreen/atmel_mxt_ts.c > @@ -3155,6 +3155,7 @@ static int __maybe_unused mxt_suspend(struct device *dev) > mxt_stop(data); > > mutex_unlock(&input_dev->mutex); > + disable_irq(data->irq); > > return 0; > } > @@ -3174,6 +3175,7 @@ static int __maybe_unused mxt_resume(struct device *dev) > mxt_start(data); > > mutex_unlock(&input_dev->mutex); > + enable_irq(data->irq); At least for older devices that do soft reset on resume we need interrupts to already work when we call mxt_start(). In general, order of resume steps should mirror suspend. Thanks. -- Dmitry 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 X-Spam-Level: X-Spam-Status: No, score=-8.3 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A9677C4360C for ; Sat, 28 Sep 2019 00:16:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 752D020679 for ; Sat, 28 Sep 2019 00:16:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="e7BPZjEF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727273AbfI1AQc (ORCPT ); Fri, 27 Sep 2019 20:16:32 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:38265 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726673AbfI1AQc (ORCPT ); Fri, 27 Sep 2019 20:16:32 -0400 Received: by mail-pl1-f196.google.com with SMTP id w8so1217312plq.5; Fri, 27 Sep 2019 17:16:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=x5OtQT6idH9LaA0kReytId/54o5wnDaqSP4igHTa5XY=; b=e7BPZjEFn4/KUlv5Ovicz7B8+NjJVVxKI1DAuSojbyeqBZ21yHH03kDleRv3QH0SpJ XyBRkOLoflo3fYMxMLbyy8FZiPclujibOSGgwfLB2blGbhvz4Dyv0iHGbphWKHjxCJTg EUCf9CUg+bcwy+nW+PXgsDr7d4Tcopz2SbD6Ttmz/3RVbvvB4qFvLpigqN+tOi2SVT6p wDZ+3bjprPDQBMYhOzBiXV/jVl/GEo3MiTbWeAmacmMe9Andi0ORV/14eFAkgRAiyrgW 2dTXYk6KO4IwWGCwg3Liu+GLbqwiO7mSHsjPzGka4tZghhBgIGOdHXocxDQ00Cv4UtGz nW9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=x5OtQT6idH9LaA0kReytId/54o5wnDaqSP4igHTa5XY=; b=cxBUXTMN1E/LEBBJF7JjxUvbSAlhAPzuUGXKJUuuA7La9afWTT5O0lWqbVW5du/4vZ IZCvwzsMZ+opyub+jIBm3FdYNBQymKabeXyhcAMCjyczJE57Myl9s8IJEaA1EigyVt9r YScjAKFom0/YmurE9rm0S0rSxb28PbYIT8hD0daUE3CzzlyJWdKpqmzTh9t/c8uo166p 1//HYt3200gjfIp6Td+JT7hqH03qd+1aBHh9q+6RqH7fIvPZh0SPjruUyKTlU5tn5wHU g7C0pcO0xdS2eOinC1Lg1W6flMu1S+IznKY3+9be76uh2Uqq+73LmTQGy1l2LWMfzLXN Yhmw== X-Gm-Message-State: APjAAAUvcgCQM83uRgfTF1aqsSZ8oQlJ5zSYXHL5vxv17bVh+H50oWp5 E+nTLqgP7zNDuB10PxKi85M= X-Google-Smtp-Source: APXvYqxyc66WqiOrnzpM4pZlBN6HZjbsmJOX1+wJ7Uz+aku8RT8PgT4DhH5Fnm/Da1L+nlxkWo7ohg== X-Received: by 2002:a17:902:b08b:: with SMTP id p11mr7886498plr.320.1569629789779; Fri, 27 Sep 2019 17:16:29 -0700 (PDT) Received: from dtor-ws ([2620:15c:202:201:3adc:b08c:7acc:b325]) by smtp.gmail.com with ESMTPSA id k31sm6940665pjb.14.2019.09.27.17.16.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Sep 2019 17:16:29 -0700 (PDT) Date: Fri, 27 Sep 2019 17:16:26 -0700 From: Dmitry Torokhov To: Evan Green Cc: Nick Dyer , Jongpil Jung , Furquan Shaikh , Rajat Jain , linux-kernel@vger.kernel.org, linux-input@vger.kernel.org Subject: Re: [PATCH v2] Input: atmel_mxt_ts - Disable IRQ across suspend Message-ID: <20190928001626.GT237523@dtor-ws> References: <20190924215238.184750-1-evgreen@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline In-Reply-To: <20190924215238.184750-1-evgreen@chromium.org> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Message-ID: <20190928001626.sb595f14omvn5_PUzdUsyTof_cP5xv_vuksCg66f-kI@z> Hi Evan, On Tue, Sep 24, 2019 at 02:52:38PM -0700, Evan Green wrote: > Across suspend and resume, we are seeing error messages like the following: > > atmel_mxt_ts i2c-PRP0001:00: __mxt_read_reg: i2c transfer failed (-121) > atmel_mxt_ts i2c-PRP0001:00: Failed to read T44 and T5 (-121) > > This occurs because the driver leaves its IRQ enabled. Upon resume, there > is an IRQ pending, but the interrupt is serviced before both the driver and > the underlying I2C bus have been resumed. This causes EREMOTEIO errors. > > Disable the IRQ in suspend, and re-enable it on resume. If there are cases > where the driver enters suspend with interrupts disabled, that's a bug we > should fix separately. > > Signed-off-by: Evan Green > --- > > Changes in v2: > - Enable and disable unconditionally (Dmitry) > > drivers/input/touchscreen/atmel_mxt_ts.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c > index 24c4b691b1c9..a58092488679 100644 > --- a/drivers/input/touchscreen/atmel_mxt_ts.c > +++ b/drivers/input/touchscreen/atmel_mxt_ts.c > @@ -3155,6 +3155,7 @@ static int __maybe_unused mxt_suspend(struct device *dev) > mxt_stop(data); > > mutex_unlock(&input_dev->mutex); > + disable_irq(data->irq); > > return 0; > } > @@ -3174,6 +3175,7 @@ static int __maybe_unused mxt_resume(struct device *dev) > mxt_start(data); > > mutex_unlock(&input_dev->mutex); > + enable_irq(data->irq); At least for older devices that do soft reset on resume we need interrupts to already work when we call mxt_start(). In general, order of resume steps should mirror suspend. Thanks. -- Dmitry