Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3172326imm; Fri, 19 Oct 2018 06:23:42 -0700 (PDT) X-Google-Smtp-Source: ACcGV62xZ+sUWn+/daWMLVoYEb0hEtSXGL4eWqPracaT59m0rp99u83Bt0FbVq5xaI3dldJMYY3o X-Received: by 2002:a62:3185:: with SMTP id x127-v6mr35681084pfx.88.1539955422150; Fri, 19 Oct 2018 06:23:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539955422; cv=none; d=google.com; s=arc-20160816; b=Z8/Dt5ze0rmegUaXTKu1igFyep9EKty1A6xO8LUxk/rzumRibPK6F9WiAQiU5v0Wjp dDJGpg56R1dbB6ihSIhZU9wWq5CmdGiaUDDDUoMZFr3rVfOdRVafTznN9oG9KDrSzmbv dhrxY8lRG+7S5//f24l88bgD4m5HEkNZT5/mEa54uGDEOqHdzn6GMmxucDo3HC1Q8STp dQceNPkaXzlScyz9e3UfGMxGUEMnWjqjJAcHu+gZD+srlvn4A72F3FE+BCj9tc/PSose iFEvDa2ieqODU04OOIgur0/j6qTtusBCpuGS1W+62RQ4ALFoVnCS/uBzHDvw9LldEodL NZRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:mime-version:message-id :date:subject:cc:to:from; bh=D1OzL+Krrnfn/sN8NoMgBPfPYz55geZZmrN5sdOs2C8=; b=hnhWMUobhTEJZZhD/AsYcR4EwSx1L55uIZOYo8oZDLekW9ZwwxoBNeugrnGj5VGJ8L 4AtGYmrTnkQj9JLlIM54eJ27bLjTb8Z1F5Pf0pR/mw12foDTZroxBU8hGS0hZL+XXjCB zpzzCNCbaimp1JuYUc4DlAgEq2HPIhfEjAPp6yCjZlVhqnjzsKHPEzBdKWUbKP544fld NAdFH449dvkWVsyMseB6FsyDbM6Ue/AqteB/YsQRUVitbqz5f+lArEuMNFMGRU+SWWyu gHNv/SmQVzV5O4wHii4M7F8oBjBDSy2yADcmL91UTbPxiLwylI9nSRkUd726Bkq+X3RS 4fRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=W2Fi8Ntv; 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=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a7-v6si24739138pgb.301.2018.10.19.06.23.26; Fri, 19 Oct 2018 06:23:42 -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=@nvidia.com header.s=n1 header.b=W2Fi8Ntv; 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=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727398AbeJSV3H (ORCPT + 99 others); Fri, 19 Oct 2018 17:29:07 -0400 Received: from hqemgate15.nvidia.com ([216.228.121.64]:14116 "EHLO hqemgate15.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727004AbeJSV3G (ORCPT ); Fri, 19 Oct 2018 17:29:06 -0400 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqemgate15.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Fri, 19 Oct 2018 06:22:54 -0700 Received: from HQMAIL103.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Fri, 19 Oct 2018 06:22:59 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Fri, 19 Oct 2018 06:22:59 -0700 Received: from HQMAIL102.nvidia.com (172.18.146.10) by HQMAIL103.nvidia.com (172.20.187.11) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Fri, 19 Oct 2018 13:22:59 +0000 Received: from HQMAIL105.nvidia.com (172.20.187.12) by HQMAIL102.nvidia.com (172.18.146.10) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Fri, 19 Oct 2018 13:22:58 +0000 Received: from hqnvemgw02.nvidia.com (172.16.227.111) by HQMAIL105.nvidia.com (172.20.187.12) with Microsoft SMTP Server (TLS) id 15.0.1395.4 via Frontend Transport; Fri, 19 Oct 2018 13:22:58 +0000 Received: from moonraker.nvidia.com (Not Verified[10.26.11.35]) by hqnvemgw02.nvidia.com with Trustwave SEG (v7,5,8,10121) id ; Fri, 19 Oct 2018 06:22:58 -0700 From: Jon Hunter To: Lee Jones CC: , , "Dmitry Osipenko" , Jonathan Hunter , Subject: [PATCH] mfd: tps6586x: Handle interrupts on suspend Date: Fri, 19 Oct 2018 14:22:53 +0100 Message-ID: <1539955373-13735-1-git-send-email-jonathanh@nvidia.com> X-Mailer: git-send-email 2.7.4 X-NVConfidentiality: public MIME-Version: 1.0 Content-Type: text/plain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1539955374; bh=D1OzL+Krrnfn/sN8NoMgBPfPYz55geZZmrN5sdOs2C8=; h=X-PGP-Universal:From:To:CC:Subject:Date:Message-ID:X-Mailer: X-NVConfidentiality:MIME-Version:Content-Type; b=W2Fi8NtvVr9iN2BQiD0MUIioUTgl6jT1azwBC7SE1gClNiNLMUumAbvZsXyCV19eI m2wJXsiY70JBBmm2pR/eZGVI+S6hcKTuJSQD791z/0sfCfSh6J7fXMEIlgAkCSEyLG MlqzaLOoTciQOB9Vuj2beq9dlnX8uBu0WwvDqMO67nCAHmdE5V+zgVFa7tGfQ7fgRS uEF/S/MdgcAfORWNi06JEpmLkSnm7op2doeBTESq6homHNV4aMM9T93zyddCg9Hf4M zhM4PEiNqnViYQh+NXqm4RfiCcXoU22JfHlYCaszKZJgRC2FPHOpNpoDI1w7rqzMNl tXEhgiQ0OSplQ== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jonathan Hunter The tps6586x driver creates an irqchip that is used by its various child devices for managing interrupts. The tps6586x-rtc device is one of its children that uses the tps6586x irqchip. When using the tps6586x-rtc as a wake-up device from suspend, the following is seen: PM: Syncing filesystems ... done. Freezing user space processes ... (elapsed 0.001 seconds) done. OOM killer disabled. Freezing remaining freezable tasks ... (elapsed 0.000 seconds) done. Disabling non-boot CPUs ... Entering suspend state LP1 Enabling non-boot CPUs ... CPU1 is up tps6586x 3-0034: failed to read interrupt status tps6586x 3-0034: failed to read interrupt status The reason why the tps6586x interrupt status cannot be read is because the tps6586x interrupt is not masked during suspend and when the tps6586x-rtc interrupt occurs, to wake-up the device, the interrupt is seen before the i2c controller has been resumed in order to read the tps6586x interrupt status. The tps6586x-rtc driver sets it's interrupt as a wake-up source during suspend, which gets propagated to the parent tps6586x interrupt. However, the tps6586x-rtc driver cannot disable it's interrupt during suspend otherwise we would never be woken up and so the tps6586x must disable it's interrupt instead. Prevent the tps6586x interrupt handler from executing on exiting suspend before the i2c controller has been resumed by disabling the tps6586x interrupt on entering suspend and re-enabling it on resuming from suspend. Cc: stable@vger.kernel.org Signed-off-by: Jon Hunter --- drivers/mfd/tps6586x.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/mfd/tps6586x.c b/drivers/mfd/tps6586x.c index b89379782741..9c7925ca13cf 100644 --- a/drivers/mfd/tps6586x.c +++ b/drivers/mfd/tps6586x.c @@ -592,6 +592,29 @@ static int tps6586x_i2c_remove(struct i2c_client *client) return 0; } +static int __maybe_unused tps6586x_i2c_suspend(struct device *dev) +{ + struct tps6586x *tps6586x = dev_get_drvdata(dev); + + if (tps6586x->client->irq) + disable_irq(tps6586x->client->irq); + + return 0; +} + +static int __maybe_unused tps6586x_i2c_resume(struct device *dev) +{ + struct tps6586x *tps6586x = dev_get_drvdata(dev); + + if (tps6586x->client->irq) + enable_irq(tps6586x->client->irq); + + return 0; +} + +static SIMPLE_DEV_PM_OPS(tps6586x_pm_ops, tps6586x_i2c_suspend, + tps6586x_i2c_resume); + static const struct i2c_device_id tps6586x_id_table[] = { { "tps6586x", 0 }, { }, @@ -602,6 +625,7 @@ static struct i2c_driver tps6586x_driver = { .driver = { .name = "tps6586x", .of_match_table = of_match_ptr(tps6586x_of_match), + .pm = &tps6586x_pm_ops, }, .probe = tps6586x_i2c_probe, .remove = tps6586x_i2c_remove, -- 2.7.4