Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp922243ybn; Wed, 25 Sep 2019 09:37:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqxvExP3mQ3iXD1mKLwz7HIA6WgjA72JhRwXmXFMSgP5Ynz5qXyJtGtB+q93ZuRKkNMpkBgd X-Received: by 2002:aa7:d688:: with SMTP id d8mr3992671edr.156.1569429479690; Wed, 25 Sep 2019 09:37:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569429479; cv=none; d=google.com; s=arc-20160816; b=uUB1LHeWN3Epnun1SmIYdngd4zhZDq1dC/0uLYmRy8OMhGrvpdWcbbvu3WKrhF9/Aw JbG64xrb7dYzLNtl5tDNsroZm76KO8e9cdXGMS0GPfzjHNgwMb2oDs8bRlBd0O8rKmXO j+itjkrPFdr/oRydQ3+5jYlyKPtzrJQKRZZpq4m8gq+Hym/0pNLoodmsvtGDIwpKiMWd Jpf6X5QFYOJZ59K47zcqnsVb67QmC0crVqQAxY58zzRACbi4jd6RasPjLPPGbO4KQUbv k1dBoBaQ/BykS0yVvmeGRL3dxgBlfSYF8c8ol+2he1/WKqiVVHEJp7q7JJIrvQreQyAH MmAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=8lkjVOpBBtIvnfc8AqZi/EJdsVEqhXIY7s5zuRbnasU=; b=fKe/AbSGSgV7qI7cjvs2JiXio332NhC7uOzuQEp4zFLVgdmo5rIrup1Zl0CRtWzEXi VVpwZcMNFst5+JuJqs0CPvkvi45eYSszboML+BsUb6Rt2Ey2VVpfqTereHeO4x/IAUyP Kl3i/sseaDl7jA2SXpZWroQdVS0WUHIFY0xxd+KD7ZjAxbTrmVec8NFelYWYVUR4pAy+ SP8Lh8AuO2gd7oVQJPvWwF4nfFgRV79tIg0x9kOnFUfb4HtrzRVvt07cZNwrcO99Y34o G6x+Bwl+9N+FomrnB0qQ1TtaOfczsYma4N1v+zvJSKXwY4N4x6n9gZ78IZUW/F48LOPg ZG4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=PzOKP8qA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p13si3815635edi.410.2019.09.25.09.37.36; Wed, 25 Sep 2019 09:37:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=PzOKP8qA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2438125AbfIWQuV (ORCPT + 99 others); Mon, 23 Sep 2019 12:50:21 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:33501 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389516AbfIWQuU (ORCPT ); Mon, 23 Sep 2019 12:50:20 -0400 Received: by mail-pl1-f194.google.com with SMTP id d22so5438628pls.0 for ; Mon, 23 Sep 2019 09:50:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=8lkjVOpBBtIvnfc8AqZi/EJdsVEqhXIY7s5zuRbnasU=; b=PzOKP8qAP9DGrZdJV556JQ6gQrZjskm445fYPVhwBmnFQu/XjhTMoBDvFOS1L9iCUa t1+x2fQMIJztXSsdUuiq2MDlf+2xnNomLibHr/2PXyfAnCCwqrapcp3xWCazmAZJZdXF zPTw/RhAu16RsLadMNoDbDIoXn7E5GHz/sQ6Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=8lkjVOpBBtIvnfc8AqZi/EJdsVEqhXIY7s5zuRbnasU=; b=dlj6aADNfswyhdDaj7fp9nHKHL7OvbtjXSoMzwW8OVFx8ywJByhj7KpZxMWosprheE eCY9Tj1rtgllhl9SspHU1BP5/ZA+a+Uc/1AW4uixNBLmqRlqfA4XwXZSE4Imqx6qi4q9 vF4kQt4ORkrertfjO8q2HnPnVzMXWXjJjN49KiPH7ulUaueGWqOawO/JRprDqhjCVC1A A6G5do9Jb3xAlGYQmp+mrNHmd7SE7xniKmRgltl3w5SwaeJtqG6RAfCcWA6xsyqQ0mHF EyprL8lCPieW8so30ab2lJpNnq/67LwY+gDMgf4wpEgs/BMHrHr8OfEPAnhuQpeOa0qx rlQQ== X-Gm-Message-State: APjAAAWd+0/Vc1rMq+Rxz8Sg2cxcnmmyWEY7oNPy0EXIMFK9UpWQpxBt otL+dFSPpYBKOowoABSYEUVQPg== X-Received: by 2002:a17:902:6bc7:: with SMTP id m7mr746474plt.60.1569257420183; Mon, 23 Sep 2019 09:50:20 -0700 (PDT) Received: from evgreen2.mtv.corp.google.com ([2620:15c:202:201:ffda:7716:9afc:1301]) by smtp.gmail.com with ESMTPSA id o195sm16534690pfg.21.2019.09.23.09.50.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 23 Sep 2019 09:50:19 -0700 (PDT) From: Evan Green To: Nick Dyer , Dmitry Torokhov Cc: Jongpil Jung , Furquan Shaikh , Rajat Jain , Evan Green , linux-kernel@vger.kernel.org, linux-input@vger.kernel.org Subject: [PATCH] Input: atmel_mxt_ts - Disable IRQ across suspend Date: Mon, 23 Sep 2019 09:50:04 -0700 Message-Id: <20190923165004.161846-1-evgreen@chromium.org> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 if it was previously enabled in resume. Signed-off-by: Evan Green --- drivers/input/touchscreen/atmel_mxt_ts.c | 33 +++++++++++++++++++----- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 24c4b691b1c9..19cbcd9767e2 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -291,6 +291,7 @@ struct mxt_data { u8 xsize; u8 ysize; bool in_bootloader; + bool irq_enabled; u16 mem_size; u8 t100_aux_ampl; u8 t100_aux_area; @@ -1185,11 +1186,23 @@ static int mxt_t6_command(struct mxt_data *data, u16 cmd_offset, return 0; } +static void mxt_enable_irq(struct mxt_data *data) +{ + enable_irq(data->irq); + data->irq_enabled = true; +} + +static void mxt_disable_irq(struct mxt_data *data) +{ + disable_irq(data->irq); + data->irq_enabled = false; +} + static int mxt_acquire_irq(struct mxt_data *data) { int error; - enable_irq(data->irq); + mxt_enable_irq(data); error = mxt_process_messages_until_invalid(data); if (error) @@ -1205,7 +1218,7 @@ static int mxt_soft_reset(struct mxt_data *data) dev_info(dev, "Resetting device\n"); - disable_irq(data->irq); + mxt_disable_irq(data); reinit_completion(&data->reset_completion); @@ -2807,7 +2820,7 @@ static int mxt_load_fw(struct device *dev, const char *fn) mxt_free_input_device(data); mxt_free_object_table(data); } else { - enable_irq(data->irq); + mxt_enable_irq(data); } reinit_completion(&data->bl_completion); @@ -2882,7 +2895,7 @@ static int mxt_load_fw(struct device *dev, const char *fn) data->in_bootloader = false; disable_irq: - disable_irq(data->irq); + mxt_disable_irq(data); release_firmware: release_firmware(fw); return ret; @@ -3101,7 +3114,7 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id) return error; } - disable_irq(client->irq); + mxt_disable_irq(data); if (data->reset_gpio) { msleep(MXT_RESET_GPIO_TIME); @@ -3132,7 +3145,7 @@ static int mxt_remove(struct i2c_client *client) { struct mxt_data *data = i2c_get_clientdata(client); - disable_irq(data->irq); + mxt_disable_irq(data); sysfs_remove_group(&client->dev.kobj, &mxt_attr_group); mxt_free_input_device(data); mxt_free_object_table(data); @@ -3156,6 +3169,11 @@ static int __maybe_unused mxt_suspend(struct device *dev) mutex_unlock(&input_dev->mutex); + /* + * Disable the IRQ directly since the boolean will be used to restore + * the IRQ state on resume. + */ + disable_irq(data->irq); return 0; } @@ -3168,6 +3186,9 @@ static int __maybe_unused mxt_resume(struct device *dev) if (!input_dev) return 0; + if (data->irq_enabled) + enable_irq(data->irq); + mutex_lock(&input_dev->mutex); if (input_dev->users) -- 2.21.0