From patchwork Fri Apr 7 06:01:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Herrenschmidt X-Patchwork-Id: 748050 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vzpqc2b34z9s2s for ; Fri, 7 Apr 2017 16:01:32 +1000 (AEST) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3vzpqc1bBXzDqJw for ; Fri, 7 Apr 2017 16:01:32 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3vzpqR604lzDqGv for ; Fri, 7 Apr 2017 16:01:23 +1000 (AEST) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.13.8) with ESMTP id v3761H1N014127 for ; Fri, 7 Apr 2017 01:01:18 -0500 Message-ID: <1491544877.4166.152.camel@kernel.crashing.org> From: Benjamin Herrenschmidt To: skiboot@lists.ozlabs.org Date: Fri, 07 Apr 2017 16:01:17 +1000 X-Mailer: Evolution 3.22.6 (3.22.6-1.fc25) Mime-Version: 1.0 Subject: [Skiboot] [PATCH 1/2] interrupts: Add an "irq_for_each_source" iterator X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" This will be used by subsequent XIVE reset improvements Signed-off-by: Benjamin Herrenschmidt --- core/interrupts.c | 12 ++++++++++++ include/interrupts.h | 6 ++++++ 2 files changed, 18 insertions(+) diff --git a/core/interrupts.c b/core/interrupts.c index 006d555..b9f4d14 100644 --- a/core/interrupts.c +++ b/core/interrupts.c @@ -126,6 +126,18 @@ struct irq_source *irq_find_source(uint32_t isn) return NULL; } +void irq_for_each_source(void (*cb)(struct irq_source *, void *), void *data) +{ + struct irq_source *is; + + lock(&irq_lock); + list_for_each(&irq_sources, is, link) + cb(is, data); + list_for_each(&irq_sources2, is, link) + cb(is, data); + unlock(&irq_lock); +} + /* * This takes a 6-bit chip id and returns a 20 bit value representing * the PSI interrupt. This includes all the fields above, ie, is a diff --git a/include/interrupts.h b/include/interrupts.h index 7576610..0376e8f 100644 --- a/include/interrupts.h +++ b/include/interrupts.h @@ -301,6 +301,12 @@ extern void register_irq_source(const struct irq_source_ops *ops, void *data, extern void unregister_irq_source(uint32_t start, uint32_t count); extern struct irq_source *irq_find_source(uint32_t isn); +/* Warning: callback is called with internal source lock held + * so don't call back into any of our irq_ APIs from it + */ +extern void irq_for_each_source(void (*cb)(struct irq_source *, void *), + void *data); + extern uint32_t get_psi_interrupt(uint32_t chip_id); extern struct dt_node *add_ics_node(void);