LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Huacai Chen <chenhuacai@gmail.com>
To: Marc Zyngier <maz@kernel.org>
Cc: Huacai Chen <chenhuacai@loongson.cn>,
Thomas Gleixner <tglx@linutronix.de>,
LKML <linux-kernel@vger.kernel.org>,
Xuefeng Li <lixuefeng@loongson.cn>,
Jiaxun Yang <jiaxun.yang@flygoat.com>
Subject: Re: [PATCH 3/9] irqchip/loongson-pch-pic: Add ACPI init support
Date: Mon, 16 Aug 2021 11:19:58 +0800 [thread overview]
Message-ID: <CAAhV-H5VWfiMu5RGjvmMTbZHJ2b7XmLB1wQcKP1VRuaEnHickw@mail.gmail.com> (raw)
In-Reply-To: <87zgtm94hr.wl-maz@kernel.org>
Hi, Marc,
On Thu, Aug 12, 2021 at 9:28 PM Marc Zyngier <maz@kernel.org> wrote:
>
> On Thu, 12 Aug 2021 13:23:27 +0100,
> Huacai Chen <chenhuacai@gmail.com> 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.
OK, I know, thanks.
Huacai
>
> M.
>
> --
> Without deviation from the norm, progress is not possible.
next prev parent reply other threads:[~2021-08-16 3:20 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-06 3:08 [PATCH 0/9] irqchip: Add LoongArch-related irqchip drivers Huacai Chen
2021-07-06 3:08 ` [PATCH 1/9] irqchip: Adjust Kconfig for Loongson Huacai Chen
2021-07-06 3:08 ` [PATCH 2/9] irqchip/loongson-pch-pic: Improve edge triggered interrupt support Huacai Chen
2021-07-06 13:06 ` Marc Zyngier
2021-07-09 3:00 ` Huacai Chen
2021-08-04 14:23 ` Marc Zyngier
2021-08-05 13:06 ` Huacai Chen
2021-07-06 3:08 ` [PATCH 3/9] irqchip/loongson-pch-pic: Add ACPI init support Huacai Chen
2021-07-06 13:10 ` Marc Zyngier
2021-07-07 4:50 ` Huacai Chen
2021-08-12 12:23 ` Huacai Chen
2021-08-12 13:28 ` Marc Zyngier
2021-08-16 3:19 ` Huacai Chen [this message]
2021-07-06 3:08 ` [PATCH 4/9] irqchip/loongson-pch-msi: " Huacai Chen
2021-07-06 13:12 ` Marc Zyngier
2021-07-07 4:51 ` Huacai Chen
2021-07-06 3:09 ` [PATCH 5/9] irqchip/loongson-htvec: " Huacai Chen
2021-07-06 13:13 ` Marc Zyngier
2021-07-07 4:52 ` Huacai Chen
2021-07-06 3:09 ` [PATCH 6/9] irqchip/loongson-liointc: " Huacai Chen
2021-07-06 3:09 ` [PATCH 7/9] irqchip: Add LoongArch CPU interrupt controller support Huacai Chen
2021-07-06 13:21 ` Marc Zyngier
2021-07-07 4:57 ` Huacai Chen
2021-07-06 3:09 ` [PATCH 8/9] irqchip: Add Loongson Extended I/O " Huacai Chen
2021-07-06 3:09 ` [PATCH 9/9] irqchip: Add Loongson PCH LPC " Huacai Chen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAAhV-H5VWfiMu5RGjvmMTbZHJ2b7XmLB1wQcKP1VRuaEnHickw@mail.gmail.com \
--to=chenhuacai@gmail.com \
--cc=chenhuacai@loongson.cn \
--cc=jiaxun.yang@flygoat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lixuefeng@loongson.cn \
--cc=maz@kernel.org \
--cc=tglx@linutronix.de \
--subject='Re: [PATCH 3/9] irqchip/loongson-pch-pic: Add ACPI init support' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).