From patchwork Mon Jan 13 09:40:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: You-Sheng Yang X-Patchwork-Id: 1222028 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47x7r01Gyyz9sQp; Mon, 13 Jan 2020 20:40:48 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1iqwDD-0003bE-D8; Mon, 13 Jan 2020 09:40:43 +0000 Received: from mail-pg1-f194.google.com ([209.85.215.194]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1iqwDB-0003au-Qs for kernel-team@lists.ubuntu.com; Mon, 13 Jan 2020 09:40:41 +0000 Received: by mail-pg1-f194.google.com with SMTP id a33so4439436pgm.5 for ; Mon, 13 Jan 2020 01:40:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LW1+fPkCv5gSDH9kj+a/iYklgCXt80vJQyPO4ZXSmyU=; b=BvSN7toyOBzN87FPynxsHwTxZUbr+7RY9OCd2aKV51+Y3g0M2ml0yMmGwi+eDShxnq 03qTi5PPejshq4iApxmTFGvuk4rhzWrIvqGv6mWzuvoT3MADSG/8ZTmSNALEtN3sEdZq Oku1vuwobkPTV07VbfW94dbawF+51vYFOmJSs0JHSMoTGFBvxsyP2TnA1WYAEZwQeh3J HTLJ+hLbtRSt+U+wDAXLVt1J47+33DfMjDgwP/r2wV8z+WleihhWGiFhBJBra/fEhLKf A72zGqcsvaGXc9CVVxy4ZhE7vuy/0sF/UhVGiN9INtdYLuMEXFd0x2HTGJSom3jeb5SU 2oIA== X-Gm-Message-State: APjAAAVLIFHSjVXjDZIAwJe20iZKZmDvMaskKVS1PKcIF2lawaYZjC0U tAygpH85GOgxaRFXF5oCpnruEw5xHSA= X-Google-Smtp-Source: APXvYqx0TZrLLF97F/REFmkncGQIDezQmscQgOzNfcHWixUXERxQlx63GMX7UH8A3H7uOtxrSHA5eg== X-Received: by 2002:aa7:9556:: with SMTP id w22mr18624967pfq.198.1578908439901; Mon, 13 Jan 2020 01:40:39 -0800 (PST) Received: from localhost (61-220-137-37.HINET-IP.hinet.net. [61.220.137.37]) by smtp.gmail.com with ESMTPSA id i2sm8810602pjs.21.2020.01.13.01.40.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jan 2020 01:40:39 -0800 (PST) From: You-Sheng Yang To: kernel-team@lists.ubuntu.com Subject: [SRU][OEM-OSP1-B/E][PATCH 1/6] PCI: irq: Introduce rearm_wake_irq() Date: Mon, 13 Jan 2020 17:40:29 +0800 Message-Id: <20200113094034.510111-2-vicamo.yang@canonical.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200113094034.510111-1-vicamo.yang@canonical.com> References: <20200113094034.510111-1-vicamo.yang@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: "Rafael J. Wysocki" BugLink: https://bugs.launchpad.net/bugs/1859407 Introduce a new function, rearm_wake_irq(), allowing a wakeup IRQ to be armed for systen wakeup detection again without running any action handlers associated with it after it has been armed for wakeup detection and triggered. That is useful for IRQs, like ACPI SCI, that may deliver wakeup as well as non-wakeup interrupts when armed for systen wakeup detection. In those cases, it may be possible to determine whether or not the delivered interrupt is a systen wakeup one without running the entire action handler (or handlers, if the IRQ is shared) for the IRQ, and if the interrupt turns out to be a non-wakeup one, the IRQ can be rearmed with the help of the new function. Signed-off-by: Rafael J. Wysocki Acked-by: Thomas Gleixner (cherry picked from commit 3a79bc63d90750f737ab9d7219bd3091d2fd6d84) Signed-off-by: You-Sheng Yang --- include/linux/interrupt.h | 1 + kernel/irq/pm.c | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h index 4a728dba02e22..3e7497432dab5 100644 --- a/include/linux/interrupt.h +++ b/include/linux/interrupt.h @@ -220,6 +220,7 @@ extern void irq_wake_thread(unsigned int irq, void *dev_id); /* The following three functions are for the core kernel use only. */ extern void suspend_device_irqs(void); extern void resume_device_irqs(void); +extern void rearm_wake_irq(unsigned int irq); /** * struct irq_affinity_notify - context for notification of IRQ affinity changes diff --git a/kernel/irq/pm.c b/kernel/irq/pm.c index d6961d3c6f9e2..8f557fa1f4fe4 100644 --- a/kernel/irq/pm.c +++ b/kernel/irq/pm.c @@ -176,6 +176,26 @@ static void resume_irqs(bool want_early) } } +/** + * rearm_wake_irq - rearm a wakeup interrupt line after signaling wakeup + * @irq: Interrupt to rearm + */ +void rearm_wake_irq(unsigned int irq) +{ + unsigned long flags; + struct irq_desc *desc = irq_get_desc_buslock(irq, &flags, IRQ_GET_DESC_CHECK_GLOBAL); + + if (!desc || !(desc->istate & IRQS_SUSPENDED) || + !irqd_is_wakeup_set(&desc->irq_data)) + return; + + desc->istate &= ~IRQS_SUSPENDED; + irqd_set(&desc->irq_data, IRQD_WAKEUP_ARMED); + __enable_irq(desc); + + irq_put_desc_busunlock(desc, flags); +} + /** * irq_pm_syscore_ops - enable interrupt lines early *