Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp549836imp; Thu, 21 Feb 2019 06:40:22 -0800 (PST) X-Google-Smtp-Source: AHgI3IZ9kPb+gN5b0SX5hx/YcK8PB6pt+QBoyGwOjGJvXkSegBO4CFLcL59B8S9u1tsLeLdOkTig X-Received: by 2002:a63:a80c:: with SMTP id o12mr38484165pgf.185.1550760022847; Thu, 21 Feb 2019 06:40:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550760022; cv=none; d=google.com; s=arc-20160816; b=IIWN+xcKrw3Ox6oUvBKqW6QiuOo2WvnL3AvZBpSJZHx9oA0KeyL2uNUPkG/1PJz4Yu OOU2E/Y3zsu4/jyddGCrl/pEbg6XX4aXHbdfHyXBiKV8tvhpvcA5aYibIKtzDZrKwD6A QoL7qcmKkf/C1xeuoZtEuxdNJ7XgAp9F74N5JdOQ/fDk45YRTkIuMWNfzo+URdX3Xiwy Y7Q6nxTkDVszcvM8a+7orRmHPhn1l7YxWp42O8ANfBRHbf8fvPH50B1MZ0rpck1Wzg3s SGALIngQIFNd2SJg1JcjI45J1sJkFtJsCSOXkno2k62QGI/FCn6CYpwZnj64USMd0E3L 8NHw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=3cdyGbpsgkGDkCct7KzOb88ZMob2KBr5CbYHolR+GHg=; b=Y4d1hj44CgSpqrh5asVOg82g/6Y3jJ8sF4eGX3RpGyUoYG+XhLcgYIp4ZJAnzNBAeg P0ES+f4qtkkluSrIGEnj544jbRlrPp04TiHZ3rO7wwRDAeuU+wxNh1v3D/tPKbhdGk6Z R98eGknOjraVMWq8aRd977qHYLIyhGFyasPdwwFMxGA5xnKjeRa6gNbISnV3JIDHn6nr sMrFFgveJIt1Mj02I9xYImAjHwFD3wIDYjWbxWbRi5gy2h8ldIp+KtVvgAr75IVM8w28 G2jxKHm6RQjB1mb84+fntyJgNPbZISWtUmzCakbgdZDErJUsKJQ/WMJcTsgaGC0eCFTb H5Ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KT2dernd; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 91si17520836plb.265.2019.02.21.06.40.07; Thu, 21 Feb 2019 06:40:22 -0800 (PST) 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=@kernel.org header.s=default header.b=KT2dernd; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728485AbfBUOhr (ORCPT + 99 others); Thu, 21 Feb 2019 09:37:47 -0500 Received: from mail.kernel.org ([198.145.29.99]:59006 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725870AbfBUOhk (ORCPT ); Thu, 21 Feb 2019 09:37:40 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 786B220838; Thu, 21 Feb 2019 14:37:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550759860; bh=8jckA824qGwV4mSIwMivLKV6Ce1ZiFg4aQ6pJxr7ffQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KT2derndQGYdGzOwtTaJN8JnCGRwDpNiJRTckC/Ku4Hu//onq7XM1rcPyeBEC3Md7 0Mdtu0wj8Rkoe2N+TIgSyrAsgkFjvQNhAQIzd5GDesB1mQxO9XEOgHxnFA0dVO29sU veZMs0eNJw2LCxsWwPm7XueiXndj6tfOoJWT/tew= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jon Hunter , Lee Jones Subject: [PATCH 4.4 15/20] mfd: as3722: Handle interrupts on suspend Date: Thu, 21 Feb 2019 15:35:45 +0100 Message-Id: <20190221141947.208324417@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190221141946.772985220@linuxfoundation.org> References: <20190221141946.772985220@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jon Hunter commit 35deff7eb212b661b32177b6043f674fde6314d7 upstream. The as3722 device is registered as an irqchip and the as3722-rtc interrupt is one of it's interrupt sources. When using the as3722-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. Freezing remaining freezable tasks ... (elapsed 0.001 seconds) done. Suspending console(s) (use no_console_suspend to debug) PM: suspend of devices complete after 161.119 msecs PM: late suspend of devices complete after 1.048 msecs PM: noirq suspend of devices complete after 0.756 msecs Disabling non-boot CPUs ... CPU1: shutdown CPU2: shutdown CPU3: shutdown Entering suspend state LP1 Enabling non-boot CPUs ... CPU1 is up CPU2 is up CPU3 is up PM: noirq resume of devices complete after 0.487 msecs as3722 4-0040: Failed to read IRQ status: -16 as3722 4-0040: Failed to read IRQ status: -16 as3722 4-0040: Failed to read IRQ status: -16 as3722 4-0040: Failed to read IRQ status: -16 ... The reason why the as3722 interrupt status cannot be read is because the as3722 interrupt is not masked during suspend and when the as3722-rtc interrupt occurs, to wake-up the device, the interrupt is seen before the i2c controller has been resumed in order to read the as3722 interrupt status. The as3722-rtc driver sets it's interrupt as a wake-up source during suspend, which gets propagated to the parent as3722 interrupt. However, the as3722-rtc driver cannot disable it's interrupt during suspend otherwise we would never be woken up and so the as3722 must disable it's interrupt instead. Fix this by disabling the as3722 interrupt during suspend. To ensure that a wake-up event from the as3722 is not missing, enable the as3722 interrupt as a wake-up source before disabling the interrupt on entering suspend. Signed-off-by: Jon Hunter Signed-off-by: Lee Jones Signed-off-by: Greg Kroah-Hartman --- drivers/mfd/as3722.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) --- a/drivers/mfd/as3722.c +++ b/drivers/mfd/as3722.c @@ -405,6 +405,8 @@ static int as3722_i2c_probe(struct i2c_c goto scrub; } + device_init_wakeup(as3722->dev, true); + dev_dbg(as3722->dev, "AS3722 core driver initialized successfully\n"); return 0; @@ -422,6 +424,29 @@ static int as3722_i2c_remove(struct i2c_ return 0; } +static int as3722_i2c_suspend(struct device *dev) +{ + struct as3722 *as3722 = dev_get_drvdata(dev); + + if (device_may_wakeup(dev)) + enable_irq_wake(as3722->chip_irq); + disable_irq(as3722->chip_irq); + + return 0; +} + +static int as3722_i2c_resume(struct device *dev) +{ + struct as3722 *as3722 = dev_get_drvdata(dev); + + enable_irq(as3722->chip_irq); + + if (device_may_wakeup(dev)) + disable_irq_wake(as3722->chip_irq); + + return 0; +} + static const struct of_device_id as3722_of_match[] = { { .compatible = "ams,as3722", }, {}, @@ -434,10 +459,15 @@ static const struct i2c_device_id as3722 }; MODULE_DEVICE_TABLE(i2c, as3722_i2c_id); +static const struct dev_pm_ops as3722_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(as3722_i2c_suspend, as3722_i2c_resume) +}; + static struct i2c_driver as3722_i2c_driver = { .driver = { .name = "as3722", .of_match_table = as3722_of_match, + .pm = &as3722_pm_ops, }, .probe = as3722_i2c_probe, .remove = as3722_i2c_remove,