Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp4229123pxa; Mon, 10 Aug 2020 04:26:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzVDxXnx/7vwTl81po7RSCUDRSi7yZOggZcu0mQnm9xx2ZdPtHpczqJjYvj1JF9r976LB75 X-Received: by 2002:aa7:de8f:: with SMTP id j15mr19794420edv.135.1597058769680; Mon, 10 Aug 2020 04:26:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597058769; cv=none; d=google.com; s=arc-20160816; b=po+dxD8D6iCHTvV1f+WPw3gBEw67UHThDZBQrhD5PwTWqJOLtfHTcltAG7ubJRsEmp LTr1722hyqnXCOLF1c6eMHcLBSd8YYuvLmHTGVpZnqNYIHNVpVjjy7EhzDokAlDC6mWF 0goKekMIZFfVM9EL9Jsx1W9SFQJxpbNMFpo0VyjLQRhGCOVRsS5LTA6brAX4BrmwZiqk Qa0Nepi+SrvTIa8gd2X534XOe1apSsXrAMw7fciekz46GeF8dBHT6UOE3/2eCIluG3Dh LtWxZqVSu3gNh81Isg2hf6kUhRm0yfiUZt1/vY6grSSD7lae3IDa4wWQGbYdTGPwz1ad 6YMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dmarc-filter:dkim-signature; bh=KHtJaMwqw4OFU9lDgwQ9JJ7ac4zj7luu1qJVM1mOZyY=; b=ewTo5W9sX7tOiGeGGVECf8bjonrcYrNbbflYSB+UVgitgplrwJfTRfzbKhMD2jv91p tF1r9YaRs8TRwNo5ysePP9ALqDP+TVM7nXKvwAqQhgWGAn/U2L9aj6lwFWSK12u545xB 0+6mDcQ4Eg1ginSAmNoN0Q3tFYufg98YV2kxI6FFCV05dZ7C9sgAwa3ON8gp92PXIZfu BT7Ii1O21bLvXV6IC6+W3j+YWblfW4zBNCQiBbq4v1bSjsSLuhmqYe+Xdck0a+6yAuB9 kDCY1ygDMdtY/qN8Vfgq3XlhVUi1/sas0E+53afhPQcwYParmIucwkaATH6GPWbk4eYr lQhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=nxaGG8Y4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q19si9820095eja.613.2020.08.10.04.25.46; Mon, 10 Aug 2020 04:26:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=nxaGG8Y4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726584AbgHJLXD (ORCPT + 99 others); Mon, 10 Aug 2020 07:23:03 -0400 Received: from m43-7.mailgun.net ([69.72.43.7]:22678 "EHLO m43-7.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726586AbgHJLVu (ORCPT ); Mon, 10 Aug 2020 07:21:50 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1597058509; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=KHtJaMwqw4OFU9lDgwQ9JJ7ac4zj7luu1qJVM1mOZyY=; b=nxaGG8Y4W0CV+jl1rHquj8KaXcpREJuVwZhIbefF7VW45ZF8xmUMA59kYl4KgQ/RxRoRc1eN nfog7ljsnYbQVOT8e5/iE8P5FelU4n6+R1VCL83FeUn9D+WMoSYQ0QoF6kKPgrMnEaHKxYrF Y5ectvD+KwaOVQ3D4cPU+z4cJbI= X-Mailgun-Sending-Ip: 69.72.43.7 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n15.prod.us-west-2.postgun.com with SMTP id 5f312dcdc85a1092b00bb4d3 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Mon, 10 Aug 2020 11:21:49 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 584D7C433AD; Mon, 10 Aug 2020 11:21:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mkshah-linux.qualcomm.com (unknown [202.46.22.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: mkshah) by smtp.codeaurora.org (Postfix) with ESMTPSA id B0A0AC43395; Mon, 10 Aug 2020 11:21:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org B0A0AC43395 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=mkshah@codeaurora.org From: Maulik Shah To: bjorn.andersson@linaro.org, maz@kernel.org, linus.walleij@linaro.org, swboyd@chromium.org, evgreen@chromium.org, mka@chromium.org Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-gpio@vger.kernel.org, agross@kernel.org, tglx@linutronix.de, jason@lakedaemon.net, dianders@chromium.org, rnayak@codeaurora.org, ilina@codeaurora.org, lsrao@codeaurora.org, Maulik Shah Subject: [PATCH v4 6/7] irqchip: qcom-pdc: Unmask wake up irqs during suspend Date: Mon, 10 Aug 2020 16:50:59 +0530 Message-Id: <1597058460-16211-7-git-send-email-mkshah@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1597058460-16211-1-git-send-email-mkshah@codeaurora.org> References: <1597058460-16211-1-git-send-email-mkshah@codeaurora.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Douglas Anderson An interrupt that is masked but set for wakeup still needs to be able to wake up the system. Use the new irq_suspend_one() and irq_resume_one() callback to handle this by unmasking at the hardware level at suspend time and putting things back at resume time. Signed-off-by: Douglas Anderson Signed-off-by: Maulik Shah --- drivers/irqchip/qcom-pdc.c | 51 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/drivers/irqchip/qcom-pdc.c b/drivers/irqchip/qcom-pdc.c index c1c5dfa..dfcdfc5 100644 --- a/drivers/irqchip/qcom-pdc.c +++ b/drivers/irqchip/qcom-pdc.c @@ -3,6 +3,7 @@ * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. */ +#include #include #include #include @@ -38,6 +39,9 @@ struct pdc_pin_region { u32 cnt; }; +static DECLARE_BITMAP(pdc_wake_irqs, PDC_MAX_IRQS); +static DECLARE_BITMAP(pdc_disabled_irqs, PDC_MAX_IRQS); + static DEFINE_RAW_SPINLOCK(pdc_lock); static void __iomem *pdc_base; static struct pdc_pin_region *pdc_region; @@ -89,11 +93,51 @@ static void pdc_enable_intr(struct irq_data *d, bool on) raw_spin_unlock(&pdc_lock); } +static void qcom_pdc_irq_suspend_one(struct irq_data *d) +{ + if (d->hwirq == GPIO_NO_WAKE_IRQ) + return; + + if (test_bit(d->hwirq, pdc_wake_irqs) && + test_bit(d->hwirq, pdc_disabled_irqs)) { + /* + * Disabled interrupts that have wake enabled need to be able + * to wake us up from suspend. Unmask them now to enable + * this. + */ + pdc_enable_intr(d, true); + irq_chip_unmask_parent(d); + } +} + +static void qcom_pdc_irq_resume_one(struct irq_data *d) +{ + if (d->hwirq == GPIO_NO_WAKE_IRQ) + return; + + if (test_bit(d->hwirq, pdc_wake_irqs) && + test_bit(d->hwirq, pdc_disabled_irqs)) { + irq_chip_mask_parent(d); + pdc_enable_intr(d, false); + } +} + +static int qcom_pdc_gic_set_wake(struct irq_data *d, unsigned int on) +{ + if (on) + set_bit(d->hwirq, pdc_wake_irqs); + else + clear_bit(d->hwirq, pdc_wake_irqs); + + return irq_chip_set_wake_parent(d, on); +} + static void qcom_pdc_gic_disable(struct irq_data *d) { if (d->hwirq == GPIO_NO_WAKE_IRQ) return; + set_bit(d->hwirq, pdc_disabled_irqs); pdc_enable_intr(d, false); irq_chip_disable_parent(d); } @@ -103,6 +147,7 @@ static void qcom_pdc_gic_enable(struct irq_data *d) if (d->hwirq == GPIO_NO_WAKE_IRQ) return; + clear_bit(d->hwirq, pdc_disabled_irqs); pdc_enable_intr(d, true); irq_chip_enable_parent(d); } @@ -201,13 +246,15 @@ static struct irq_chip qcom_pdc_gic_chip = { .irq_unmask = qcom_pdc_gic_unmask, .irq_disable = qcom_pdc_gic_disable, .irq_enable = qcom_pdc_gic_enable, + .irq_set_wake = qcom_pdc_gic_set_wake, + .irq_suspend_one = qcom_pdc_irq_suspend_one, + .irq_resume_one = qcom_pdc_irq_resume_one, .irq_get_irqchip_state = qcom_pdc_gic_get_irqchip_state, .irq_set_irqchip_state = qcom_pdc_gic_set_irqchip_state, .irq_retrigger = irq_chip_retrigger_hierarchy, .irq_set_type = qcom_pdc_gic_set_type, .flags = IRQCHIP_MASK_ON_SUSPEND | - IRQCHIP_SET_TYPE_MASKED | - IRQCHIP_SKIP_SET_WAKE, + IRQCHIP_SET_TYPE_MASKED, .irq_set_vcpu_affinity = irq_chip_set_vcpu_affinity_parent, .irq_set_affinity = irq_chip_set_affinity_parent, }; -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation