devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Frank Li <frank.li@nxp.com>
Cc: "tglx@linutronix.de" <tglx@linutronix.de>,
	"robh+dt@kernel.org" <robh+dt@kernel.org>,
	"krzysztof.kozlowski+dt@linaro.org" 
	<krzysztof.kozlowski+dt@linaro.org>,
	"shawnguo@kernel.org" <shawnguo@kernel.org>,
	"s.hauer@pengutronix.de" <s.hauer@pengutronix.de>,
	"kw@linux.com" <kw@linux.com>,
	"bhelgaas@google.com" <bhelgaas@google.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linux-arm-kernel@lists.infradead.org" 
	<linux-arm-kernel@lists.infradead.org>,
	"linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
	Peng Fan <peng.fan@nxp.com>, Aisheng Dong <aisheng.dong@nxp.com>,
	"jdmason@kudzu.us" <jdmason@kudzu.us>,
	"kernel@pengutronix.de" <kernel@pengutronix.de>,
	"festevam@gmail.com" <festevam@gmail.com>,
	dl-linux-imx <linux-imx@nxp.com>, "kishon@ti.com" <kishon@ti.com>,
	"lorenzo.pieralisi@arm.com" <lorenzo.pieralisi@arm.com>,
	"ntb@lists.linux.dev" <ntb@lists.linux.dev>
Subject: Re: [EXT] Re: [PATCH 1/3] irqchip: imx mu worked as msi controller
Date: Sat, 09 Jul 2022 09:16:18 +0100	[thread overview]
Message-ID: <87fsja1z1p.wl-maz@kernel.org> (raw)
In-Reply-To: <PAXPR04MB9186714350C749DB6AADB35188829@PAXPR04MB9186.eurprd04.prod.outlook.com>

On Fri, 08 Jul 2022 17:26:33 +0100,
Frank Li <frank.li@nxp.com> wrote:
> 
> 
> 
> > -----Original Message-----
> > From: Marc Zyngier <maz@kernel.org>
> > Sent: Friday, July 8, 2022 3:59 AM
> > To: Frank Li <frank.li@nxp.com>
> > Cc: tglx@linutronix.de; robh+dt@kernel.org;
> > krzysztof.kozlowski+dt@linaro.org; shawnguo@kernel.org;
> > s.hauer@pengutronix.de; kw@linux.com; bhelgaas@google.com; linux-
> > kernel@vger.kernel.org; devicetree@vger.kernel.org; linux-arm-
> > kernel@lists.infradead.org; linux-pci@vger.kernel.org; Peng Fan
> > <peng.fan@nxp.com>; Aisheng Dong <aisheng.dong@nxp.com>;
> > jdmason@kudzu.us; kernel@pengutronix.de; festevam@gmail.com; dl-linux-
> > imx <linux-imx@nxp.com>; kishon@ti.com; lorenzo.pieralisi@arm.com;
> > ntb@lists.linux.dev
> > Subject: [EXT] Re: [PATCH 1/3] irqchip: imx mu worked as msi controller
> > 
> > Caution: EXT Email
> > 
> > On Thu, 07 Jul 2022 22:02:36 +0100,
> > Frank Li <Frank.Li@nxp.com> wrote:
> > >
> > > MU support generate irq by write data to a register.
> > > This patch make mu worked as msi controller.
> > > So MU can do doorbell by using standard msi api.
> > >
> > > Signed-off-by: Frank Li <Frank.Li@nxp.com>
> > > ---
> > >  drivers/irqchip/Kconfig          |   7 +
> > >  drivers/irqchip/Makefile         |   1 +
> > >  drivers/irqchip/irq-imx-mu-msi.c | 490
> > +++++++++++++++++++++++++++++++
> > >  3 files changed, 498 insertions(+)
> > >  create mode 100644 drivers/irqchip/irq-imx-mu-msi.c
> > >

[...]

> > > +static void imx_mu_msi_mask_irq(struct irq_data *data)
> > > +{
> > > +     struct imx_mu_msi *msi_data = irq_data_get_irq_chip_data(data-
> > >parent_data);
> > > +
> > > +     pci_msi_mask_irq(data);
> > 
> > What is this? Below, you create a platform MSI domain. Either you
> > support PCI, and you create a PCI/MSI domain (and the above may make
> > sense), or you are doing platform MSI, and the above is non-sense.
> 
> [Frank Li] You are right. This work as platform msi. Needn't call pci_msi_irq()  

OK, hold that thought and see below.

> > > +static int imx_mu_msi_domain_irq_alloc(struct irq_domain *domain,
> > > +                                     unsigned int virq,
> > > +                                     unsigned int nr_irqs,
> > > +                                     void *args)
> > > +{
> > > +     struct imx_mu_msi *msi_data = domain->host_data;
> > > +     msi_alloc_info_t *info = args;
> > > +     int pos, err = 0;
> > > +
> > > +     pm_runtime_get_sync(&msi_data->pdev->dev);
> > 
> > The core code already deals with runtime PM. What prevents it from
> > working, other than the fact you don't populate the device in the
> > top-level domain?
> 
> [Frank Li]  Do you means power domain or irq domain?

IRQ domain. See irq_domain_set_pm_device() and how PM is used on
interrupt request.

[...]

> > > +static void imx_mu_msi_domain_irq_free(struct irq_domain *domain,
> > > +                                    unsigned int virq, unsigned int nr_irqs)
> > > +{
> > > +     struct irq_data *d = irq_domain_get_irq_data(domain, virq);
> > > +     struct imx_mu_msi *msi_data = irq_data_get_irq_chip_data(d);
> > > +     int pos;
> > > +
> > > +     pos = d->hwirq;
> > > +     if (pos < 0 || pos >= msi_data->irqs_num) {
> > > +             pr_err("failed to teardown msi. Invalid hwirq %d\n", pos);
> > > +             return;
> > > +     }
> > 
> > How can this happen?
> 
> I just copy from irq-ls-scfg-msi.c

I wish you didn't do that.

> It should be impossible happen if everything work as expected. 

Then it should go.

[...]

> > > +static const struct imx_mu_dcfg imx_mu_cfg_imx6sx = {
> > > +     .xTR    = 0x0,
> > > +     .xRR    = 0x10,
> > > +     .xSR    = {0x20, 0x20, 0x20, 0x20},
> > > +     .xCR    = {0x24, 0x24, 0x24, 0x24},
> > > +};
> > > +
> > > +static const struct imx_mu_dcfg imx_mu_cfg_imx7ulp = {
> > > +     .xTR    = 0x20,
> > > +     .xRR    = 0x40,
> > > +     .xSR    = {0x60, 0x60, 0x60, 0x60},
> > > +     .xCR    = {0x64, 0x64, 0x64, 0x64},
> > > +};
> > > +
> > > +static const struct imx_mu_dcfg imx_mu_cfg_imx8ulp = {
> > > +     .type   = IMX_MU_V2,
> > > +     .xTR    = 0x200,
> > > +     .xRR    = 0x280,
> > > +     .xSR    = {0xC, 0x118, 0x124, 0x12C},
> > > +     .xCR    = {0x110, 0x114, 0x120, 0x128},
> > > +};
> > > +
> > > +static const struct imx_mu_dcfg imx_mu_cfg_imx8ulp_s4 = {
> > > +     .type   = IMX_MU_V2 | IMX_MU_V2_S4,
> > > +     .xTR    = 0x200,
> > > +     .xRR    = 0x280,
> > > +     .xSR    = {0xC, 0x118, 0x124, 0x12C},
> > > +     .xCR    = {0x110, 0x114, 0x120, 0x128},
> > > +};
> > 
> > What are these? We really don't need more magic numbers.
> 
> It is register offset.  The difference version MU hardware's
> register map is difference.

Then please document what this is, what the various registers are, and
correctly set type everywhere.

[...]

> > If that's hardcoded, why do we need an extra variable? I also question
> > the usefulness of this driver if the HW can only deal with *4* MSIs...
> > This looks a bit like a joke.
> 
> MU don't really MSI controller.  Each MU have 4 channel.  
> I.MX have several MU units.

Then is it really useful to model that as a MSI controller? This
smells of a mailbox controller to me instead. And I really worry that
this device doesn't correctly preserve the ordering between a device
doing DMA and generating an interrupt to indicate completion of the
DMA transaction... Does this block offers such a guarantee?

> PCI EP driver need an address as doorbell,  so PCI RC side can write
> This address to trigger irq.  Ideally,  it use GIC-ITS. But our i.MX chip
> Have not ITS support yet now.  So we can use MU as simple MSI controller.

Is that an integrated EP on the same SoC? Or are you talking of two
SoCs connected over PCIe? Also, you explicitly said that this was
*not* a PCI/MSI controller. So what is this all about?

[...]

> > > +static int imx_mu_msi_remove(struct platform_device *pdev)
> > > +{
> > > +     struct imx_mu_msi *msi_data = platform_get_drvdata(pdev);
> > > +
> > > +     imx_mu_msi_teardown_hwirq(msi_data);
> > > +
> > > +     irq_domain_remove(msi_data->msi_domain);
> > > +     irq_domain_remove(msi_data->parent);
> > 
> > How do you ensure that no device is still holding interrupts? Let me
> > give you a hint: you can't. So removing an interrupt controller module
> > should not be possible.
> 
> [Frank Li] I agree. But there are many *_remove under irqchip.

That doesn't make it right.

Thanks,

	M.

-- 
Without deviation from the norm, progress is not possible.

  reply	other threads:[~2022-07-09  8:16 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-07 21:02 [PATCH 1/3] irqchip: imx mu worked as msi controller Frank Li
2022-07-07 21:02 ` [PATCH 2/3] dt-bindings: irqchip: imx mu work " Frank Li
2022-07-08 21:32   ` Rob Herring
2022-07-12 10:25   ` Krzysztof Kozlowski
2022-07-15 19:35     ` [EXT] " Frank Li
2022-07-07 21:02 ` [PATCH 3/3] pcie: endpoint: pci-epf-vntb: add endpoint msi support Frank Li
2022-07-08  8:01 ` [PATCH 1/3] irqchip: imx mu worked as msi controller Marc Zyngier
2022-07-08  8:58 ` Marc Zyngier
2022-07-08 16:26   ` [EXT] " Frank Li
2022-07-09  8:16     ` Marc Zyngier [this message]
2022-07-09 15:23       ` Frank Li
2022-07-13 18:28         ` Frank Li

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=87fsja1z1p.wl-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=aisheng.dong@nxp.com \
    --cc=bhelgaas@google.com \
    --cc=devicetree@vger.kernel.org \
    --cc=festevam@gmail.com \
    --cc=frank.li@nxp.com \
    --cc=jdmason@kudzu.us \
    --cc=kernel@pengutronix.de \
    --cc=kishon@ti.com \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=kw@linux.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=ntb@lists.linux.dev \
    --cc=peng.fan@nxp.com \
    --cc=robh+dt@kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=shawnguo@kernel.org \
    --cc=tglx@linutronix.de \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).