From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=BAYES_00,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A8E85C4338F for ; Thu, 12 Aug 2021 13:28:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 84F49604D7 for ; Thu, 12 Aug 2021 13:28:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237553AbhHLN3B (ORCPT ); Thu, 12 Aug 2021 09:29:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:33786 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232081AbhHLN3A (ORCPT ); Thu, 12 Aug 2021 09:29:00 -0400 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 563A560FC3; Thu, 12 Aug 2021 13:28:35 +0000 (UTC) Received: from sofa.misterjones.org ([185.219.108.64] helo=why.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 1mEAl7-004Yub-BY; Thu, 12 Aug 2021 14:28:33 +0100 Date: Thu, 12 Aug 2021 14:28:32 +0100 Message-ID: <87zgtm94hr.wl-maz@kernel.org> From: Marc Zyngier To: Huacai Chen Cc: Huacai Chen , Thomas Gleixner , LKML , Xuefeng Li , Jiaxun Yang Subject: Re: [PATCH 3/9] irqchip/loongson-pch-pic: Add ACPI init support In-Reply-To: References: <20210706030904.1411775-1-chenhuacai@loongson.cn> <20210706030904.1411775-4-chenhuacai@loongson.cn> <877di38u5c.wl-maz@kernel.org> 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: 185.219.108.64 X-SA-Exim-Rcpt-To: chenhuacai@gmail.com, chenhuacai@loongson.cn, tglx@linutronix.de, linux-kernel@vger.kernel.org, lixuefeng@loongson.cn, jiaxun.yang@flygoat.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 12 Aug 2021 13:23:27 +0100, Huacai Chen wrote: > [...] > > > > +struct fwnode_handle *pch_pic_acpi_init(struct fwnode_handle *parent, > > > > + struct acpi_madt_bio_pic *acpi_pchpic) > > > > +{ > > > > + int count; > > > > + struct pch_pic *priv; > > > > + struct irq_domain *parent_domain; > > > > + > > > > + priv = kzalloc(sizeof(*priv), GFP_KERNEL); > > > > + if (!priv) > > > > + return NULL; > > > > + > > > > + raw_spin_lock_init(&priv->pic_lock); > > > > + priv->base = ioremap(acpi_pchpic->address, acpi_pchpic->size); > > > > + if (!priv->base) > > > > + goto free_priv; > > > > + > > > > + priv->domain_handle = irq_domain_alloc_fwnode(priv->base); > > > > + if (!priv->domain_handle) { > > > > + pr_err("Unable to allocate domain handle\n"); > > > > + goto iounmap_base; > > > > + } > > > > + > > > > + priv->ht_vec_base = acpi_pchpic->gsi_base; > > > > + count = ((readq(priv->base) >> 48) & 0xff) + 1; > > > > + parent_domain = irq_find_matching_fwnode(parent, DOMAIN_BUS_ANY); > > > > + if (!parent_domain) { > > > > + pr_err("Failed to find the parent domain\n"); > > > > + goto iounmap_base; > > > > + } > > > > + > > > > + priv->pic_domain = irq_domain_create_hierarchy(parent_domain, 0, > > > > + count, priv->domain_handle, > > > > + &pch_pic_domain_ops, priv); > > > > + > > > > + if (!priv->pic_domain) { > > > > + pr_err("Failed to create IRQ domain\n"); > > > > + goto iounmap_base; > > > > + } > > > > + > > > > + pch_pic_reset(priv); > > > > + pch_pic_priv[nr_pch_pics++] = priv; > > > > + > > > > + register_syscore_ops(&pch_pic_syscore_ops); > > > > + > > > > + return priv->domain_handle; > > > > + > > > > +iounmap_base: > > > > + iounmap(priv->base); > > > > +free_priv: > > > > + kfree(priv); > > > > + > > > > + return NULL; > > > > +} > > > > + > > > > +#endif > > > > > > A lot of this code is common with its OF counterpart. How about making > > > this logic common? > > OK, let me think about. > Though pch_pic_acpi_init() is similar to pch_pic_of_init(), but it is > difficult to make a common function, because we cannot prepare > everything before the common function. For example, ioremap() can be > the common part, but pch_pic_acpi_init() should get the vector count > after ioremap(). If we use an argument to distinguish the caller in > the common function, the complexity increases and seems no benefits. All firmware implementations allocate private data structures, irq domains, map MMIO regions, etc. All that can be common. We even have APIs that deal with both firmware interfaces. As for the 'read the vector count from the HW', what does it have to do with driving the HW using DT or ACPI? The HW doesn't *know*. If you are conflating HW changes and firmware interfaces, then you have already lost. M. -- Without deviation from the norm, progress is not possible.