Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2358589iof; Wed, 8 Jun 2022 03:19:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzv6dMTvhbTh6Vu5MyWdkn0k3r8vHzZ5HWj3rNMFi2VtvFIQTecMQ/DeGttM3Q2wAv5WhrQ X-Received: by 2002:a63:fe16:0:b0:3fe:3f58:dcff with SMTP id p22-20020a63fe16000000b003fe3f58dcffmr1052262pgh.342.1654683566548; Wed, 08 Jun 2022 03:19:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654683566; cv=none; d=google.com; s=arc-20160816; b=ZbcwSaWNViRaJVnFKih4ipGfc81UfC0l/ZyIIW24gYqmSCWfrANCFfZ0yfS0vBccN+ bSgzHYHF8FCCASHxOQOtIMXNOh6GBby73hD5UISJm3ogt7tzneJwavzh7P57yHmUpBvh GrfKkVIi2Sn2c+bg4XbHpHaU971zyCfzxbWcIMxT9k4jvspZXrraXHy97/GLvfUnIIHR dmhXYvIdPOAAxCRt5qkVxKeCYxXnI9hkVKRSmcaSCRWJmlxqoirQc0hRsed1qsgJN8V+ Xx98lLHVwRfmpuEjjuEf/SIBW+wt3OrFrRugHxv1N7bbXuAg35y0X63K15LQpxtxH1xy vXuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature; bh=Hx71MU2UmitiNdrS+1x8DNTDbSV9gjxRWDhICH1LiBo=; b=z6SOvxB09hAjXp94oupei8kTSGOzHsAq4LEh84VAUjPrJe9EMQXACvPc+5V02K6Dvk HV0qkmOVakpOqpSGBu0u/DVkhnnrubeK7GUiMTvL1b/6eTWB+ToobGX6D5PDVX/00WNZ ZYd3lfDGlbuEDvol8vGjBJwERjIBZ3LoELubLFK6n79cA8ZbB71WCS+qKy3O0deLcxMS TxW400XqBVqVxwvVjE1yWOosouKsXC0Xb9cG7hRXNa2b0GdtKBRGG3jCzMKC2uAhpEWb x0WUpox3bJ8IiKodIchfk9WcXPS3zQUY/RlvVnr2tEPb+vcb0XL9E1w/R8dfU6fdY6zM TLug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BNB6o7oF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id c12-20020a655a8c000000b003fa8a90ca7bsi27721123pgt.498.2022.06.08.03.19.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 03:19:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BNB6o7oF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7B6481775E5; Wed, 8 Jun 2022 02:46:47 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235302AbiFHJql (ORCPT + 99 others); Wed, 8 Jun 2022 05:46:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235283AbiFHJpX (ORCPT ); Wed, 8 Jun 2022 05:45:23 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3219B1CB708 for ; Wed, 8 Jun 2022 02:12:39 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id D3C1FCE250D for ; Wed, 8 Jun 2022 09:12:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E073CC34116; Wed, 8 Jun 2022 09:12:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1654679555; bh=I7SnWuQ1bjRokJm9BUmaGBmzA4PNyEstkEE07J/J15s=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=BNB6o7oFyHspaw2c8vzp9j90/CuiknmkES2bOBp0yVVREhygxeTU9swRR+jVC+xM/ 32t7Kgme/reHTcGCGp26eflAJxtLDAeHUalZ5gCZ/+g6d3xC6cqxUr8o+J+w05Wi0a JQlUz5MJGWDbaoQ1b0Tv6/VuciE/LMOuOp1uHzw1NTzi+jlXA0YxihrP3vnbaW+Z1p xw7Rc+LwyE8lLWhAl7Q0Q+nC5rX2uVpHmD0X+V2EcT3byrHriFwDo6RkAh21IjCpXj hYuOGEfPLSyIeFkN2CkY5Addv0DrLyPvjB3gvsN+uteTXyhQX+VAq2+XYTNT2aPtGC ea4V00mTTUXBg== Received: from [104.132.45.110] (helo=wait-a-minute.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nyrjt-00GYGo-A9; Wed, 08 Jun 2022 10:12:33 +0100 Date: Wed, 08 Jun 2022 10:12:29 +0100 Message-ID: <871qvzr01u.wl-maz@kernel.org> From: Marc Zyngier To: Aswath Govindraju Cc: Vignesh Raghavendra , Nishanth Menon , Tero Kristo , Santosh Shilimkar , Thomas Gleixner , , Subject: Re: [PATCH] irqchip/ti-sci-intr: Add support for system suspend/resume PM In-Reply-To: <0733f59a-497a-351b-0e97-26a2875a5352@ti.com> References: <20220607061912.12222-1-a-govindraju@ti.com> <87sfohyma5.wl-maz@kernel.org> <0733f59a-497a-351b-0e97-26a2875a5352@ti.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 104.132.45.110 X-SA-Exim-Rcpt-To: a-govindraju@ti.com, vigneshr@ti.com, nm@ti.com, kristo@kernel.org, ssantosh@kernel.org, tglx@linutronix.de, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 08 Jun 2022 09:48:20 +0100, Aswath Govindraju wrote: > > Hi Marc, > > On 07/06/22 12:48, Marc Zyngier wrote: > > On Tue, 07 Jun 2022 07:19:12 +0100, > > Aswath Govindraju wrote: > >> > >> Add support for system level suspend/resume power management. The > >> interrupt mappings are stored in an array and restored in the system level > >> resume routine. Struct ti_sci_resource_desc can have atmost 2 sets for > >> ranges. Therefore, the mapping array is also formatted such that it can > >> store two sets of ranges. > >> > >> Signed-off-by: Aswath Govindraju > >> --- > >> drivers/irqchip/irq-ti-sci-intr.c | 108 ++++++++++++++++++++++++++++++ > >> 1 file changed, 108 insertions(+) > >> > >> diff --git a/drivers/irqchip/irq-ti-sci-intr.c b/drivers/irqchip/irq-ti-sci-intr.c > >> index fe8fad22bcf9..a8fc6cfb96ca 100644 > >> --- a/drivers/irqchip/irq-ti-sci-intr.c > >> +++ b/drivers/irqchip/irq-ti-sci-intr.c > >> @@ -25,6 +25,7 @@ > >> * @dev: Struct device pointer. > >> * @ti_sci_id: TI-SCI device identifier > >> * @type: Specifies the trigger type supported by this Interrupt Router > >> + * @mapping: Pointer to out_irq <-> hwirq mapping table > >> */ > >> struct ti_sci_intr_irq_domain { > >> const struct ti_sci_handle *sci; > >> @@ -32,6 +33,7 @@ struct ti_sci_intr_irq_domain { > >> struct device *dev; > >> u32 ti_sci_id; > >> u32 type; > >> + u32 *mapping; > >> }; > >> > >> static struct irq_chip ti_sci_intr_irq_chip = { > >> @@ -99,6 +101,23 @@ static int ti_sci_intr_xlate_irq(struct ti_sci_intr_irq_domain *intr, u32 irq) > >> return -ENOENT; > >> } > >> > >> +/** > >> + * ti_sci_intr_free_irq - Free the irq entry in the out_irq <-> hwirq mapping table > >> + * @intr: IRQ domain corresponding to Interrupt Router > >> + * @out_irq: Out irq number > >> + */ > >> +static void ti_sci_intr_free_irq(struct ti_sci_intr_irq_domain *intr, u16 out_irq) > >> +{ > >> + u16 start = intr->out_irqs->desc->start; > >> + u16 num = intr->out_irqs->desc->num; > >> + u16 start_sec = intr->out_irqs->desc->start_sec; > >> + > >> + if (out_irq < start + num) > >> + intr->mapping[out_irq - start] = 0xFFFFFFFF; > >> + else > >> + intr->mapping[out_irq - start_sec + num] = 0xFFFFFFFF; > >> +} > >> + > >> /** > >> * ti_sci_intr_irq_domain_free() - Free the specified IRQs from the domain. > >> * @domain: Domain to which the irqs belong > >> @@ -118,11 +137,30 @@ static void ti_sci_intr_irq_domain_free(struct irq_domain *domain, > >> intr->sci->ops.rm_irq_ops.free_irq(intr->sci, > >> intr->ti_sci_id, data->hwirq, > >> intr->ti_sci_id, out_irq); > >> + ti_sci_intr_free_irq(intr, out_irq); > >> ti_sci_release_resource(intr->out_irqs, out_irq); > >> irq_domain_free_irqs_parent(domain, virq, 1); > >> irq_domain_reset_irq_data(data); > >> } > >> > >> +/** > >> + * ti_sci_intr_add_irq - Add the irq entry in the out_irq <-> hwirq mapping table > >> + * @intr: IRQ domain corresponding to Interrupt Router > >> + * @hwirq: Input irq number > >> + * @out_irq: Out irq number > >> + */ > >> +static void ti_sci_intr_add_irq(struct ti_sci_intr_irq_domain *intr, u32 hwirq, u16 out_irq) > >> +{ > >> + u16 start = intr->out_irqs->desc->start; > >> + u16 num = intr->out_irqs->desc->num; > >> + u16 start_sec = intr->out_irqs->desc->start_sec; > >> + > >> + if (out_irq < start + num) > >> + intr->mapping[out_irq - start] = hwirq; > >> + else > >> + intr->mapping[out_irq - start_sec + num] = hwirq; > >> +} > > > > I'll bite: you already have a full resource allocator that is used for > > all sort of things. Why isn't this cached by the resource allocator > > itself? Why is this an irqchip specific thing? I expect other users of > > the same API to have the same needs. > > > > As, the resource allocator does not have enough memory to save and > restore all the mappings corresponding various resources, this is being > done on the requester or consumer side. You're missing the point: the ti_sci_resource structure is managed by this resource allocator, and it isn't exactly rocket science to add the required context to it, and then get it to restore that context on resume. This would actually give a sense of purpose to this stuff, which is otherwise pretty useless. M. -- Without deviation from the norm, progress is not possible.