From patchwork Tue Apr 4 12:03:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Benjamin Herrenschmidt X-Patchwork-Id: 746765 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 3vy70t4NsNz9s8F for ; Tue, 4 Apr 2017 22:03:42 +1000 (AEST) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3vy70t30hSzDqJL for ; Tue, 4 Apr 2017 22:03:42 +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 3vy70n2bjYzDq7c for ; Tue, 4 Apr 2017 22:03:37 +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 v34C3P5T020771 for ; Tue, 4 Apr 2017 07:03:27 -0500 Message-ID: <1491307405.4166.40.camel@kernel.crashing.org> From: Benjamin Herrenschmidt To: skiboot@lists.ozlabs.org Date: Tue, 04 Apr 2017 22:03:25 +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(+)    extern struct dt_node *add_ics_node(void); 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);