Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp4655659pxv; Tue, 6 Jul 2021 06:17:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzxymyXlCezAysmtEgkALLnHKhjNgUw5WFOYv/8ups1fW4Tdg3OVXr4nIe0qoSxjTfq8P37 X-Received: by 2002:aa7:cfd8:: with SMTP id r24mr13469074edy.323.1625577427219; Tue, 06 Jul 2021 06:17:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625577427; cv=none; d=google.com; s=arc-20160816; b=gK+kqvVV9X7e+6Ope8Z+8fgdhqv95sXRAIeTBt4/uoN+U6xJW7DuQyym0+xOXbK8hI C0EB308GpqpnzhygSjaEzNY1Qf70aowCoZjM9oueu36K9ijI9SjBMfqvfiboXZuIoFJ+ kqYCuWb2gwjXZIOohCR1xXmWvoHFb/EkCwg4SjfnTwXsSJ+hQ3lpK+mULQy1CN3mcAl9 b1b7TAmd/JLP029VbtcewizWjptMhGEQ9u0y7I1xaMBpUF8xqW77EuVSwhAxnd92D0ry 6hdQsEoHeoaQj9cM+sNy/1oRNUvYdsTQMl6KMBQlrfmUclSD3SkxnC2R2/sSwxhETxBP kNrg== 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; bh=8K+ADiUU5K9TG4oTzLHLXknfOkl/Jkq58zZm1IeW17Y=; b=E4ZBt7H8HWx5RhF/oZCTcbBJxOI5spNpiRAq1yErjF2VZpGc2/I/KqZlG10lyUOSfk hHmMG0uibCn72qV+ug8XLCJyYsDGLBq3j29RUvtJFvKgBu523qnX3+A+ii2fiBUusBx8 aZ0qKwEIqEpnIOLpZclHWwuCrt2Jr0CiB8+qfzhe/SbUsVP3vXQuSjEd4Cx4Q1oxp1h6 SXYnyxDWZo+1u4SshgVqPYpCppYjTRXoK4LyNSja9rCBwHLICXGcqm9L4FYTvzSjbgc+ di9iJJFuV1dfydCusIkO+kCYwFx0xP+gcvqT6s9GK3Nm6loMy+lgj/eZFq56Samv1BtB kkMQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ca8si935874edb.158.2021.07.06.06.16.44; Tue, 06 Jul 2021 06:17:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232089AbhGFNPP (ORCPT + 99 others); Tue, 6 Jul 2021 09:15:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:60690 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231546AbhGFNPM (ORCPT ); Tue, 6 Jul 2021 09:15:12 -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 DE2EE61C82; Tue, 6 Jul 2021 13:12:33 +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 1m0ksJ-00Bjh9-SB; Tue, 06 Jul 2021 14:12:32 +0100 Date: Tue, 06 Jul 2021 14:12:31 +0100 Message-ID: <875yxn8u2o.wl-maz@kernel.org> From: Marc Zyngier To: Huacai Chen Cc: Thomas Gleixner , linux-kernel@vger.kernel.org, Xuefeng Li , Huacai Chen , Jiaxun Yang Subject: Re: [PATCH 4/9] irqchip/loongson-pch-msi: Add ACPI init support In-Reply-To: <20210706030904.1411775-5-chenhuacai@loongson.cn> References: <20210706030904.1411775-1-chenhuacai@loongson.cn> <20210706030904.1411775-5-chenhuacai@loongson.cn> 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@loongson.cn, tglx@linutronix.de, linux-kernel@vger.kernel.org, lixuefeng@loongson.cn, chenhuacai@gmail.com, 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 Tue, 06 Jul 2021 04:08:59 +0100, Huacai Chen wrote: > > We are preparing to add new Loongson (based on LoongArch, not MIPS) > support. LoongArch use ACPI other than DT as its boot protocol, so > add ACPI init support. > > Signed-off-by: Huacai Chen > --- > drivers/irqchip/irq-loongson-pch-msi.c | 69 ++++++++++++++++++++++++-- > 1 file changed, 64 insertions(+), 5 deletions(-) > > diff --git a/drivers/irqchip/irq-loongson-pch-msi.c b/drivers/irqchip/irq-loongson-pch-msi.c > index 32562b7e681b..adfa30046f0a 100644 > --- a/drivers/irqchip/irq-loongson-pch-msi.c > +++ b/drivers/irqchip/irq-loongson-pch-msi.c > @@ -1,6 +1,8 @@ > // SPDX-License-Identifier: GPL-2.0 > /* > * Copyright (C) 2020, Jiaxun Yang > + * Jianmin Lv > + * Huacai Chen Same thing as the previous patch: drop it. > * Loongson PCH MSI support > */ > > @@ -21,6 +23,7 @@ struct pch_msi_data { > u32 irq_first; /* The vector number that MSIs starts */ > u32 num_irqs; /* The number of vectors for MSIs */ > unsigned long *msi_map; > + struct fwnode_handle *domain_handle; > }; > > static void pch_msi_mask_msi_irq(struct irq_data *d) > @@ -159,7 +162,12 @@ static int pch_msi_init_domains(struct pch_msi_data *priv, > { > struct irq_domain *middle_domain, *msi_domain; > > - middle_domain = irq_domain_create_linear(of_node_to_fwnode(node), > + if (node) > + priv->domain_handle = of_node_to_fwnode(node); > + else > + priv->domain_handle = irq_domain_alloc_fwnode((phys_addr_t *)priv); > + > + middle_domain = irq_domain_create_linear(priv->domain_handle, > priv->num_irqs, > &pch_msi_middle_domain_ops, > priv); > @@ -171,7 +179,7 @@ static int pch_msi_init_domains(struct pch_msi_data *priv, > middle_domain->parent = parent; > irq_domain_update_bus_token(middle_domain, DOMAIN_BUS_NEXUS); > > - msi_domain = pci_msi_create_irq_domain(of_node_to_fwnode(node), > + msi_domain = pci_msi_create_irq_domain(priv->domain_handle, > &pch_msi_domain_info, > middle_domain); > if (!msi_domain) { > @@ -183,8 +191,9 @@ static int pch_msi_init_domains(struct pch_msi_data *priv, > return 0; > } > > -static int pch_msi_init(struct device_node *node, > - struct device_node *parent) > +#ifdef CONFIG_OF > + > +int pch_msi_of_init(struct device_node *node, struct device_node *parent) > { > struct pch_msi_data *priv; > struct irq_domain *parent_domain; > @@ -247,4 +256,54 @@ static int pch_msi_init(struct device_node *node, > return ret; > } > > -IRQCHIP_DECLARE(pch_msi, "loongson,pch-msi-1.0", pch_msi_init); > +IRQCHIP_DECLARE(pch_msi, "loongson,pch-msi-1.0", pch_msi_of_init); > + > +#endif > + > +#ifdef CONFIG_ACPI > + > +struct fwnode_handle *pch_msi_acpi_init(struct fwnode_handle *parent, > + struct acpi_madt_msi_pic *acpi_pchmsi) > +{ > + int ret; > + struct pch_msi_data *priv; > + struct irq_domain *parent_domain; > + > + priv = kzalloc(sizeof(*priv), GFP_KERNEL); > + if (!priv) > + return NULL; > + > + mutex_init(&priv->msi_map_lock); > + > + priv->doorbell = acpi_pchmsi->msg_address; > + priv->irq_first = acpi_pchmsi->start; > + priv->num_irqs = acpi_pchmsi->count; > + > + parent_domain = irq_find_matching_fwnode(parent, DOMAIN_BUS_ANY); > + if (!parent_domain) { > + pr_err("Failed to find the parent domain\n"); > + return NULL; > + } > + > + priv->msi_map = bitmap_zalloc(priv->num_irqs, GFP_KERNEL); > + if (!priv->msi_map) > + goto err_priv; > + > + pr_debug("Registering %d MSIs, starting at %d\n", > + priv->num_irqs, priv->irq_first); > + > + ret = pch_msi_init_domains(priv, NULL, parent_domain); > + if (ret) > + goto err_map; > + > + return priv->domain_handle; > + > +err_map: > + kfree(priv->msi_map); > +err_priv: > + kfree(priv); > + > + return NULL; > +} > + > +#endif Same thing. You are pointlessly duplicating the logic. M. -- Without deviation from the norm, progress is not possible.