[v13,15/21] PCI: microchip: Add event irqchip field to host port and add PLDA irqchip
Message ID | 20231214072839.2367-16-minda.chen@starfivetech.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp8374107dys; Wed, 13 Dec 2023 23:31:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IEjUB5om8p3gJdx8F/Li263XVgKPGg0kOwoQ1JrIzi5o/rK6+HzXun1PfflB7XGo5XOYh4k X-Received: by 2002:a17:90b:d83:b0:28a:fbb5:7605 with SMTP id bg3-20020a17090b0d8300b0028afbb57605mr1695041pjb.2.1702539088086; Wed, 13 Dec 2023 23:31:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702539088; cv=none; d=google.com; s=arc-20160816; b=dsNbpzf0auNllAwAKsL0OM6Y3TILLpNDwPC5sQJyKimLJM/Y/TiY10tUmnXt2eqiD1 Ibr32YWanCnV3Hj0h9W7oyerc42MLWhM+PDBEuU5tvw4k+sWxUZHH4QiLw4miOJZaAlh LaRN/7YOF5c+5OX9BGcJC/MaU19SWJgtUPHbDPOlCADPndesqbhT/rVsntIxbVtYmRet NrWf0RjRdrsYIPrZKIm8ej+dkIHYMPfIHyDkUmz2uzD6a7vRYH+XhWpAjkr16HLNDLuN xHV6aGkHQGfqEp4ZDYQH+mqoKbcKIiLA0s0drKSAGkaxuK7n+wUL9pjHbBd2DeLT7Vbv qzMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=+d9eEOyAH85yy/7zmoHS6SSfCyGlXSar+WNS7ocMznQ=; fh=ld3UXb1S5Y4IkunPfuj6e9Ppmc+fy6ncC+eQtrVLfK8=; b=M1qAV+Pn3v7vFefGEWsA9kOmBletMSq96bWtmL1gJTFXZsTSVZwvLotf12h8LWIxUW rkK7cxgiG2YsGu9Z9baGjnIyIpOPB+iyh7P7D2IDhur0tzeOLf6XpYZfk0jaAgmVkNhY 197cr71lynAk5dgB3tN4YLJMzbGu0Ee7dvERCaKDRrTXjf/oMN6Fzgu8wCvbSJ0dkHhW JehcTDAN13WlJQSEobis/H2SOhFiLtg5TTepraVLnkROJ2k4ujDMXg69QklhTarwEspJ Dw0stmCj3DTXxs6j68SNuDMqe+RR/51CskDAjDMtETkl7mwqOGmwLIqkA/GSKefn2myS hUVA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id a6-20020a17090a854600b0028b0daf81aasi325829pjw.181.2023.12.13.23.31.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 23:31:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 6E02180842FD; Wed, 13 Dec 2023 23:30:42 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1443429AbjLNHa0 (ORCPT <rfc822;dexuan.linux@gmail.com> + 99 others); Thu, 14 Dec 2023 02:30:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1443417AbjLNH3w (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 14 Dec 2023 02:29:52 -0500 Received: from ex01.ufhost.com (ex01.ufhost.com [61.152.239.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB5BD194; Wed, 13 Dec 2023 23:29:38 -0800 (PST) Received: from EXMBX165.cuchost.com (unknown [175.102.18.54]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "EXMBX165", Issuer "EXMBX165" (not verified)) by ex01.ufhost.com (Postfix) with ESMTP id A214B24E304; Thu, 14 Dec 2023 15:29:37 +0800 (CST) Received: from EXMBX171.cuchost.com (172.16.6.91) by EXMBX165.cuchost.com (172.16.6.75) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Thu, 14 Dec 2023 15:29:37 +0800 Received: from ubuntu.localdomain (113.72.145.168) by EXMBX171.cuchost.com (172.16.6.91) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Thu, 14 Dec 2023 15:29:35 +0800 From: Minda Chen <minda.chen@starfivetech.com> To: Conor Dooley <conor@kernel.org>, =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= <kw@linux.com>, Rob Herring <robh+dt@kernel.org>, Bjorn Helgaas <bhelgaas@google.com>, Lorenzo Pieralisi <lpieralisi@kernel.org>, "Daire McNamara" <daire.mcnamara@microchip.com>, Emil Renner Berthing <emil.renner.berthing@canonical.com>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org> CC: <devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>, <linux-riscv@lists.infradead.org>, <linux-pci@vger.kernel.org>, Paul Walmsley <paul.walmsley@sifive.com>, Palmer Dabbelt <palmer@dabbelt.com>, Albert Ou <aou@eecs.berkeley.edu>, Philipp Zabel <p.zabel@pengutronix.de>, Mason Huo <mason.huo@starfivetech.com>, Leyfoon Tan <leyfoon.tan@starfivetech.com>, Kevin Xie <kevin.xie@starfivetech.com>, Minda Chen <minda.chen@starfivetech.com> Subject: [PATCH v13 15/21] PCI: microchip: Add event irqchip field to host port and add PLDA irqchip Date: Thu, 14 Dec 2023 15:28:33 +0800 Message-ID: <20231214072839.2367-16-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20231214072839.2367-1-minda.chen@starfivetech.com> References: <20231214072839.2367-1-minda.chen@starfivetech.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [113.72.145.168] X-ClientProxiedBy: EXCAS064.cuchost.com (172.16.6.24) To EXMBX171.cuchost.com (172.16.6.91) X-YovoleRuleAgent: yovoleflag X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 agentk.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 13 Dec 2023 23:30:42 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785241626682720901 X-GMAIL-MSGID: 1785241626682720901 |
Series |
Refactoring Microchip PCIe driver and add StarFive PCIe
|
|
Commit Message
Minda Chen
Dec. 14, 2023, 7:28 a.m. UTC
PolarFire PCIE event IRQs includes PLDA local interrupts and PolarFire
their own IRQs. PolarFire PCIe event irq_chip ops using an event_desc to
unify different IRQ register addresses. On PLDA sides, PLDA irqchip codes
only require to set PLDA local interrupt register. So the PLDA irqchip ops
codes can not be extracted from PolarFire codes.
To support PLDA its own event IRQ process, implements PLDA irqchip ops and
add event irqchip field to struct pcie_plda_rp.
Signed-off-by: Minda Chen <minda.chen@starfivetech.com>
---
.../pci/controller/plda/pcie-microchip-host.c | 65 ++++++++++++++++++-
drivers/pci/controller/plda/pcie-plda.h | 3 +
2 files changed, 67 insertions(+), 1 deletion(-)
Comments
On 2023/12/14 15:28, Minda Chen wrote: > PolarFire PCIE event IRQs includes PLDA local interrupts and PolarFire > their own IRQs. PolarFire PCIe event irq_chip ops using an event_desc to > unify different IRQ register addresses. On PLDA sides, PLDA irqchip codes > only require to set PLDA local interrupt register. So the PLDA irqchip ops > codes can not be extracted from PolarFire codes. > > To support PLDA its own event IRQ process, implements PLDA irqchip ops and > add event irqchip field to struct pcie_plda_rp. > > Signed-off-by: Minda Chen <minda.chen@starfivetech.com> > --- > .../pci/controller/plda/pcie-microchip-host.c | 65 ++++++++++++++++++- > drivers/pci/controller/plda/pcie-plda.h | 3 + > 2 files changed, 67 insertions(+), 1 deletion(-) > Hi Conor Could you take time to review this patch? For I using event irq chip instead of event ops and the whole patch have been changed. I think it's better And I added the implementation of PLDA event irqchip and make it easier to claim the necessity of the modification. If you approve this, I will add back the review tag. Thanks Hi Lorenzo Have you reviewed this patch? Does the commit message and the codes are can be approved ?Thanks > diff --git a/drivers/pci/controller/plda/pcie-microchip-host.c b/drivers/pci/controller/plda/pcie-microchip-host.c > index fd0d92c3d03f..ff40c1622173 100644 > --- a/drivers/pci/controller/plda/pcie-microchip-host.c > +++ b/drivers/pci/controller/plda/pcie-microchip-host.c > @@ -771,6 +771,63 @@ static struct irq_chip mc_event_irq_chip = { > .irq_unmask = mc_unmask_event_irq, > }; > > +static u32 plda_hwirq_to_mask(int hwirq) > +{ > + u32 mask; > + > + if (hwirq < EVENT_PM_MSI_INT_INTX) > + mask = BIT(hwirq + A_ATR_EVT_POST_ERR_SHIFT); > + else if (hwirq == EVENT_PM_MSI_INT_INTX) > + mask = PM_MSI_INT_INTX_MASK; > + else > + mask = BIT(hwirq + PM_MSI_TO_MASK_OFFSET); > + > + return mask; > +} > + > +static void plda_ack_event_irq(struct irq_data *data) > +{ > + struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); > + > + writel_relaxed(plda_hwirq_to_mask(data->hwirq), > + port->bridge_addr + ISTATUS_LOCAL); > +} > + > +static void plda_mask_event_irq(struct irq_data *data) > +{ > + struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); > + u32 mask, val; > + > + mask = plda_hwirq_to_mask(data->hwirq); > + > + raw_spin_lock(&port->lock); > + val = readl_relaxed(port->bridge_addr + IMASK_LOCAL); > + val &= ~mask; > + writel_relaxed(val, port->bridge_addr + IMASK_LOCAL); > + raw_spin_unlock(&port->lock); > +} > + > +static void plda_unmask_event_irq(struct irq_data *data) > +{ > + struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); > + u32 mask, val; > + > + mask = plda_hwirq_to_mask(data->hwirq); > + > + raw_spin_lock(&port->lock); > + val = readl_relaxed(port->bridge_addr + IMASK_LOCAL); > + val |= mask; > + writel_relaxed(val, port->bridge_addr + IMASK_LOCAL); > + raw_spin_unlock(&port->lock); > +} > + > +static struct irq_chip plda_event_irq_chip = { > + .name = "PLDA PCIe EVENT", > + .irq_ack = plda_ack_event_irq, > + .irq_mask = plda_mask_event_irq, > + .irq_unmask = plda_unmask_event_irq, > +}; > + > static const struct plda_event_ops plda_event_ops = { > .get_events = plda_get_events, > }; > @@ -778,7 +835,9 @@ static const struct plda_event_ops plda_event_ops = { > static int plda_pcie_event_map(struct irq_domain *domain, unsigned int irq, > irq_hw_number_t hwirq) > { > - irq_set_chip_and_handler(irq, &mc_event_irq_chip, handle_level_irq); > + struct plda_pcie_rp *port = (void *)domain->host_data; > + > + irq_set_chip_and_handler(irq, port->event_irq_chip, handle_level_irq); > irq_set_chip_data(irq, domain->host_data); > > return 0; > @@ -963,6 +1022,9 @@ static int plda_init_interrupts(struct platform_device *pdev, > if (!port->event_ops) > port->event_ops = &plda_event_ops; > > + if (!port->event_irq_chip) > + port->event_irq_chip = &plda_event_irq_chip; > + > ret = plda_pcie_init_irq_domains(port); > if (ret) { > dev_err(dev, "failed creating IRQ domains\n"); > @@ -1040,6 +1102,7 @@ static int mc_platform_init(struct pci_config_window *cfg) > return ret; > > port->plda.event_ops = &mc_event_ops; > + port->plda.event_irq_chip = &mc_event_irq_chip; > > /* Address translation is up; safe to enable interrupts */ > ret = plda_init_interrupts(pdev, &port->plda, &mc_event); > diff --git a/drivers/pci/controller/plda/pcie-plda.h b/drivers/pci/controller/plda/pcie-plda.h > index dd8bc2750bfc..24ac50c458dc 100644 > --- a/drivers/pci/controller/plda/pcie-plda.h > +++ b/drivers/pci/controller/plda/pcie-plda.h > @@ -128,6 +128,8 @@ > * DMA end : reserved for vendor implement > */ > > +#define PM_MSI_TO_MASK_OFFSET 19 > + > struct plda_pcie_rp; > > struct plda_event_ops { > @@ -150,6 +152,7 @@ struct plda_pcie_rp { > raw_spinlock_t lock; > struct plda_msi msi; > const struct plda_event_ops *event_ops; > + const struct irq_chip *event_irq_chip; > void __iomem *bridge_addr; > int num_events; > };
On Thu, Dec 21, 2023 at 06:56:22PM +0800, Minda Chen wrote: > > > On 2023/12/14 15:28, Minda Chen wrote: > > PolarFire PCIE event IRQs includes PLDA local interrupts and PolarFire > > their own IRQs. PolarFire PCIe event irq_chip ops using an event_desc to > > unify different IRQ register addresses. On PLDA sides, PLDA irqchip codes > > only require to set PLDA local interrupt register. So the PLDA irqchip ops > > codes can not be extracted from PolarFire codes. > > > > To support PLDA its own event IRQ process, implements PLDA irqchip ops and > > add event irqchip field to struct pcie_plda_rp. > > > > Signed-off-by: Minda Chen <minda.chen@starfivetech.com> > > --- > > .../pci/controller/plda/pcie-microchip-host.c | 65 ++++++++++++++++++- > > drivers/pci/controller/plda/pcie-plda.h | 3 + > > 2 files changed, 67 insertions(+), 1 deletion(-) > > > Hi Conor > Could you take time to review this patch? For I using event irq chip instead of event ops and the whole patch have been changed. I think it's better > And I added the implementation of PLDA event irqchip and make it easier to claim the necessity of the modification. > If you approve this, I will add back the review tag. Thanks > > Hi Lorenzo > Have you reviewed this patch? Does the commit message and the codes are can be approved ?Thanks > Please wrap the lines at 75 columns in length. I have not reviewed but I am still struggling to understand the commit log, I apologise, I can try to review the series and figure out what the patch is doing but I would appreciate if commits logs could be made easier to parse. Thanks, Lorenzo > > diff --git a/drivers/pci/controller/plda/pcie-microchip-host.c b/drivers/pci/controller/plda/pcie-microchip-host.c > > index fd0d92c3d03f..ff40c1622173 100644 > > --- a/drivers/pci/controller/plda/pcie-microchip-host.c > > +++ b/drivers/pci/controller/plda/pcie-microchip-host.c > > @@ -771,6 +771,63 @@ static struct irq_chip mc_event_irq_chip = { > > .irq_unmask = mc_unmask_event_irq, > > }; > > > +static u32 plda_hwirq_to_mask(int hwirq) > > +{ > > + u32 mask; > > + > > + if (hwirq < EVENT_PM_MSI_INT_INTX) > > + mask = BIT(hwirq + A_ATR_EVT_POST_ERR_SHIFT); > > + else if (hwirq == EVENT_PM_MSI_INT_INTX) > > + mask = PM_MSI_INT_INTX_MASK; > > + else > > + mask = BIT(hwirq + PM_MSI_TO_MASK_OFFSET); > > + > > + return mask; > > +} > > + > > +static void plda_ack_event_irq(struct irq_data *data) > > +{ > > + struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); > > + > > + writel_relaxed(plda_hwirq_to_mask(data->hwirq), > > + port->bridge_addr + ISTATUS_LOCAL); > > +} > > + > > +static void plda_mask_event_irq(struct irq_data *data) > > +{ > > + struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); > > + u32 mask, val; > > + > > + mask = plda_hwirq_to_mask(data->hwirq); > > + > > + raw_spin_lock(&port->lock); > > + val = readl_relaxed(port->bridge_addr + IMASK_LOCAL); > > + val &= ~mask; > > + writel_relaxed(val, port->bridge_addr + IMASK_LOCAL); > > + raw_spin_unlock(&port->lock); > > +} > > + > > +static void plda_unmask_event_irq(struct irq_data *data) > > +{ > > + struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); > > + u32 mask, val; > > + > > + mask = plda_hwirq_to_mask(data->hwirq); > > + > > + raw_spin_lock(&port->lock); > > + val = readl_relaxed(port->bridge_addr + IMASK_LOCAL); > > + val |= mask; > > + writel_relaxed(val, port->bridge_addr + IMASK_LOCAL); > > + raw_spin_unlock(&port->lock); > > +} > > + > > +static struct irq_chip plda_event_irq_chip = { > > + .name = "PLDA PCIe EVENT", > > + .irq_ack = plda_ack_event_irq, > > + .irq_mask = plda_mask_event_irq, > > + .irq_unmask = plda_unmask_event_irq, > > +}; > > + > > static const struct plda_event_ops plda_event_ops = { > > .get_events = plda_get_events, > > }; > > @@ -778,7 +835,9 @@ static const struct plda_event_ops plda_event_ops = { > > static int plda_pcie_event_map(struct irq_domain *domain, unsigned int irq, > > irq_hw_number_t hwirq) > > { > > - irq_set_chip_and_handler(irq, &mc_event_irq_chip, handle_level_irq); > > + struct plda_pcie_rp *port = (void *)domain->host_data; > > + > > + irq_set_chip_and_handler(irq, port->event_irq_chip, handle_level_irq); > > irq_set_chip_data(irq, domain->host_data); > > > > return 0; > > @@ -963,6 +1022,9 @@ static int plda_init_interrupts(struct platform_device *pdev, > > if (!port->event_ops) > > port->event_ops = &plda_event_ops; > > > > + if (!port->event_irq_chip) > > + port->event_irq_chip = &plda_event_irq_chip; > > + > > ret = plda_pcie_init_irq_domains(port); > > if (ret) { > > dev_err(dev, "failed creating IRQ domains\n"); > > @@ -1040,6 +1102,7 @@ static int mc_platform_init(struct pci_config_window *cfg) > > return ret; > > > > port->plda.event_ops = &mc_event_ops; > > + port->plda.event_irq_chip = &mc_event_irq_chip; > > > > /* Address translation is up; safe to enable interrupts */ > > ret = plda_init_interrupts(pdev, &port->plda, &mc_event); > > diff --git a/drivers/pci/controller/plda/pcie-plda.h b/drivers/pci/controller/plda/pcie-plda.h > > index dd8bc2750bfc..24ac50c458dc 100644 > > --- a/drivers/pci/controller/plda/pcie-plda.h > > +++ b/drivers/pci/controller/plda/pcie-plda.h > > @@ -128,6 +128,8 @@ > > * DMA end : reserved for vendor implement > > */ > > > > +#define PM_MSI_TO_MASK_OFFSET 19 > > + > > struct plda_pcie_rp; > > > > struct plda_event_ops { > > @@ -150,6 +152,7 @@ struct plda_pcie_rp { > > raw_spinlock_t lock; > > struct plda_msi msi; > > const struct plda_event_ops *event_ops; > > + const struct irq_chip *event_irq_chip; > > void __iomem *bridge_addr; > > int num_events; > > };
On 2023/12/21 23:32, Lorenzo Pieralisi wrote: > On Thu, Dec 21, 2023 at 06:56:22PM +0800, Minda Chen wrote: >> >> >> On 2023/12/14 15:28, Minda Chen wrote: >> > PolarFire PCIE event IRQs includes PLDA local interrupts and PolarFire >> > their own IRQs. PolarFire PCIe event irq_chip ops using an event_desc to >> > unify different IRQ register addresses. On PLDA sides, PLDA irqchip codes >> > only require to set PLDA local interrupt register. So the PLDA irqchip ops >> > codes can not be extracted from PolarFire codes. >> > >> > To support PLDA its own event IRQ process, implements PLDA irqchip ops and >> > add event irqchip field to struct pcie_plda_rp. >> > >> > Signed-off-by: Minda Chen <minda.chen@starfivetech.com> >> > --- >> > .../pci/controller/plda/pcie-microchip-host.c | 65 ++++++++++++++++++- >> > drivers/pci/controller/plda/pcie-plda.h | 3 + >> > 2 files changed, 67 insertions(+), 1 deletion(-) >> > >> Hi Conor >> Could you take time to review this patch? For I using event irq chip instead of event ops and the whole patch have been changed. I think it's better >> And I added the implementation of PLDA event irqchip and make it easier to claim the necessity of the modification. >> If you approve this, I will add back the review tag. Thanks >> >> Hi Lorenzo >> Have you reviewed this patch? Does the commit message and the codes are can be approved ?Thanks >> > > Please wrap the lines at 75 columns in length. > OK > I have not reviewed but I am still struggling to understand the > commit log, I apologise, I can try to review the series and figure > out what the patch is doing but I would appreciate if commits logs > could be made easier to parse. > > Thanks, > Lorenzo > The commit message it is not good. I draw a graph about the PCIe global event interrupt domain (related to patch 10- 16). Actually all these interrupts patches are for extracting the common PLDA codes to pcie-plda-host.c and do not change microchip's codes logic. +----------------------------------------------------------+ | microchip Global event interrupt domain | +-----------------------------------+-----------+----------+ | | microchip | PLDA | | | event num |(StarFive)| | | |event num | +-----------------------------------+-----------+----------+ | | 0 | | | | | | (mc pcie |microchip platform event interrupt | | | int line) | | | | ------------| | | | | |10 | | +-----------------------------------+-----------+----------+ | PLDA host DMA interrupt |11 | | | (int number is not fixed, defined | | | | by vendor) |14 | | +--+-----------------------------------+---------- +----------+-+ | | PLDA event interrupt |15 |0 | | | | (int number is fixed) | | | | ---------|--| | | | | (Starfive| | | | | | pcie int | | +------------------+ | | | | line) | | |INTx event domain | | | | | | | +------------------+ | | | | | | | | | | | | +------------------+ | | | | | | |MSI event domain | | | | | | | +------------------+ | | | | | | |27 |12 | | | +---------------------------------+-+-----------+----------+ | | extract PLDA event part to common PLDA file. | +---------------------------------------------------------------+ >> > diff --git a/drivers/pci/controller/plda/pcie-microchip-host.c b/drivers/pci/controller/plda/pcie-microchip-host.c >> > index fd0d92c3d03f..ff40c1622173 100644 >> > --- a/drivers/pci/controller/plda/pcie-microchip-host.c >> > +++ b/drivers/pci/controller/plda/pcie-microchip-host.c >> > @@ -771,6 +771,63 @@ static struct irq_chip mc_event_irq_chip = { >> > .irq_unmask = mc_unmask_event_irq, >> > }; >> > > +static u32 plda_hwirq_to_mask(int hwirq) >> > +{ >> > + u32 mask; >> > + >> > + if (hwirq < EVENT_PM_MSI_INT_INTX) >> > + mask = BIT(hwirq + A_ATR_EVT_POST_ERR_SHIFT); >> > + else if (hwirq == EVENT_PM_MSI_INT_INTX) >> > + mask = PM_MSI_INT_INTX_MASK; >> > + else >> > + mask = BIT(hwirq + PM_MSI_TO_MASK_OFFSET); >> > + >> > + return mask; >> > +} >> > + >> > +static void plda_ack_event_irq(struct irq_data *data) >> > +{ >> > + struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); >> > + >> > + writel_relaxed(plda_hwirq_to_mask(data->hwirq), >> > + port->bridge_addr + ISTATUS_LOCAL); >> > +} >> > + >> > +static void plda_mask_event_irq(struct irq_data *data) >> > +{ >> > + struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); >> > + u32 mask, val; >> > + >> > + mask = plda_hwirq_to_mask(data->hwirq); >> > + >> > + raw_spin_lock(&port->lock); >> > + val = readl_relaxed(port->bridge_addr + IMASK_LOCAL); >> > + val &= ~mask; >> > + writel_relaxed(val, port->bridge_addr + IMASK_LOCAL); >> > + raw_spin_unlock(&port->lock); >> > +} >> > + >> > +static void plda_unmask_event_irq(struct irq_data *data) >> > +{ >> > + struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); >> > + u32 mask, val; >> > + >> > + mask = plda_hwirq_to_mask(data->hwirq); >> > + >> > + raw_spin_lock(&port->lock); >> > + val = readl_relaxed(port->bridge_addr + IMASK_LOCAL); >> > + val |= mask; >> > + writel_relaxed(val, port->bridge_addr + IMASK_LOCAL); >> > + raw_spin_unlock(&port->lock); >> > +} >> > + >> > +static struct irq_chip plda_event_irq_chip = { >> > + .name = "PLDA PCIe EVENT", >> > + .irq_ack = plda_ack_event_irq, >> > + .irq_mask = plda_mask_event_irq, >> > + .irq_unmask = plda_unmask_event_irq, >> > +}; >> > + >> > static const struct plda_event_ops plda_event_ops = { >> > .get_events = plda_get_events, >> > }; >> > @@ -778,7 +835,9 @@ static const struct plda_event_ops plda_event_ops = { >> > static int plda_pcie_event_map(struct irq_domain *domain, unsigned int irq, >> > irq_hw_number_t hwirq) >> > { >> > - irq_set_chip_and_handler(irq, &mc_event_irq_chip, handle_level_irq); >> > + struct plda_pcie_rp *port = (void *)domain->host_data; >> > + >> > + irq_set_chip_and_handler(irq, port->event_irq_chip, handle_level_irq); >> > irq_set_chip_data(irq, domain->host_data); >> > >> > return 0; >> > @@ -963,6 +1022,9 @@ static int plda_init_interrupts(struct platform_device *pdev, >> > if (!port->event_ops) >> > port->event_ops = &plda_event_ops; >> > >> > + if (!port->event_irq_chip) >> > + port->event_irq_chip = &plda_event_irq_chip; >> > + >> > ret = plda_pcie_init_irq_domains(port); >> > if (ret) { >> > dev_err(dev, "failed creating IRQ domains\n"); >> > @@ -1040,6 +1102,7 @@ static int mc_platform_init(struct pci_config_window *cfg) >> > return ret; >> > >> > port->plda.event_ops = &mc_event_ops; >> > + port->plda.event_irq_chip = &mc_event_irq_chip; >> > >> > /* Address translation is up; safe to enable interrupts */ >> > ret = plda_init_interrupts(pdev, &port->plda, &mc_event); >> > diff --git a/drivers/pci/controller/plda/pcie-plda.h b/drivers/pci/controller/plda/pcie-plda.h >> > index dd8bc2750bfc..24ac50c458dc 100644 >> > --- a/drivers/pci/controller/plda/pcie-plda.h >> > +++ b/drivers/pci/controller/plda/pcie-plda.h >> > @@ -128,6 +128,8 @@ >> > * DMA end : reserved for vendor implement >> > */ >> > >> > +#define PM_MSI_TO_MASK_OFFSET 19 >> > + >> > struct plda_pcie_rp; >> > >> > struct plda_event_ops { >> > @@ -150,6 +152,7 @@ struct plda_pcie_rp { >> > raw_spinlock_t lock; >> > struct plda_msi msi; >> > const struct plda_event_ops *event_ops; >> > + const struct irq_chip *event_irq_chip; >> > void __iomem *bridge_addr; >> > int num_events; >> > };
[+Thomas] On Fri, Dec 22, 2023 at 07:18:48PM +0800, Minda Chen wrote: > > > On 2023/12/21 23:32, Lorenzo Pieralisi wrote: > > On Thu, Dec 21, 2023 at 06:56:22PM +0800, Minda Chen wrote: > >> > >> > >> On 2023/12/14 15:28, Minda Chen wrote: > >> > PolarFire PCIE event IRQs includes PLDA local interrupts and PolarFire > >> > their own IRQs. PolarFire PCIe event irq_chip ops using an event_desc to > >> > unify different IRQ register addresses. On PLDA sides, PLDA irqchip codes > >> > only require to set PLDA local interrupt register. So the PLDA irqchip ops > >> > codes can not be extracted from PolarFire codes. > >> > > >> > To support PLDA its own event IRQ process, implements PLDA irqchip ops and > >> > add event irqchip field to struct pcie_plda_rp. > >> > > >> > Signed-off-by: Minda Chen <minda.chen@starfivetech.com> > >> > --- > >> > .../pci/controller/plda/pcie-microchip-host.c | 65 ++++++++++++++++++- > >> > drivers/pci/controller/plda/pcie-plda.h | 3 + > >> > 2 files changed, 67 insertions(+), 1 deletion(-) > >> > > >> Hi Conor > >> Could you take time to review this patch? For I using event irq chip instead of event ops and the whole patch have been changed. I think it's better > >> And I added the implementation of PLDA event irqchip and make it easier to claim the necessity of the modification. > >> If you approve this, I will add back the review tag. Thanks > >> > >> Hi Lorenzo > >> Have you reviewed this patch? Does the commit message and the codes are can be approved ?Thanks > >> > > > > Please wrap the lines at 75 columns in length. > > > OK > > I have not reviewed but I am still struggling to understand the > > commit log, I apologise, I can try to review the series and figure > > out what the patch is doing but I would appreciate if commits logs > > could be made easier to parse. > > > > Thanks, > > Lorenzo > > > > The commit message it is not good. > > I draw a graph about the PCIe global event interrupt domain > (related to patch 10- 16). > Actually all these interrupts patches are for extracting the common > PLDA codes to pcie-plda-host.c and do not change microchip's codes logic. s/codes/code (please apply this to the the full series) I will have a look at the code but I can't rewrite the commit log myself (it does not scale I am afraid), as it stands I don't understand it and that's a problem, I am sorry but that's important. I added Thomas (you should CC him for irqchip [only] changes) if he has time to review these irqchip changes to make sure they are proper. Thanks, Lorenzo > +----------------------------------------------------------+ > | microchip Global event interrupt domain | > +-----------------------------------+-----------+----------+ > | | microchip | PLDA | > | | event num |(StarFive)| > | | |event num | > +-----------------------------------+-----------+----------+ > | | 0 | | > | | | | > (mc pcie |microchip platform event interrupt | | | > int line) | | | | > ------------| | | | > | |10 | | > +-----------------------------------+-----------+----------+ > | PLDA host DMA interrupt |11 | | > | (int number is not fixed, defined | | | > | by vendor) |14 | | > +--+-----------------------------------+---------- +----------+-+ > | | PLDA event interrupt |15 |0 | | > | | (int number is fixed) | | | | > ---------|--| | | | | > (Starfive| | | | | | > pcie int | | +------------------+ | | | | > line) | | |INTx event domain | | | | | > | | +------------------+ | | | | > | | | | | | > | | +------------------+ | | | | > | | |MSI event domain | | | | | > | | +------------------+ | | | | > | | |27 |12 | | > | +---------------------------------+-+-----------+----------+ | > | extract PLDA event part to common PLDA file. | > +---------------------------------------------------------------+ > > > >> > diff --git a/drivers/pci/controller/plda/pcie-microchip-host.c b/drivers/pci/controller/plda/pcie-microchip-host.c > >> > index fd0d92c3d03f..ff40c1622173 100644 > >> > --- a/drivers/pci/controller/plda/pcie-microchip-host.c > >> > +++ b/drivers/pci/controller/plda/pcie-microchip-host.c > >> > @@ -771,6 +771,63 @@ static struct irq_chip mc_event_irq_chip = { > >> > .irq_unmask = mc_unmask_event_irq, > >> > }; > >> > > +static u32 plda_hwirq_to_mask(int hwirq) > >> > +{ > >> > + u32 mask; > >> > + > >> > + if (hwirq < EVENT_PM_MSI_INT_INTX) > >> > + mask = BIT(hwirq + A_ATR_EVT_POST_ERR_SHIFT); > >> > + else if (hwirq == EVENT_PM_MSI_INT_INTX) > >> > + mask = PM_MSI_INT_INTX_MASK; > >> > + else > >> > + mask = BIT(hwirq + PM_MSI_TO_MASK_OFFSET); > >> > + > >> > + return mask; > >> > +} > >> > + > >> > +static void plda_ack_event_irq(struct irq_data *data) > >> > +{ > >> > + struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); > >> > + > >> > + writel_relaxed(plda_hwirq_to_mask(data->hwirq), > >> > + port->bridge_addr + ISTATUS_LOCAL); > >> > +} > >> > + > >> > +static void plda_mask_event_irq(struct irq_data *data) > >> > +{ > >> > + struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); > >> > + u32 mask, val; > >> > + > >> > + mask = plda_hwirq_to_mask(data->hwirq); > >> > + > >> > + raw_spin_lock(&port->lock); > >> > + val = readl_relaxed(port->bridge_addr + IMASK_LOCAL); > >> > + val &= ~mask; > >> > + writel_relaxed(val, port->bridge_addr + IMASK_LOCAL); > >> > + raw_spin_unlock(&port->lock); > >> > +} > >> > + > >> > +static void plda_unmask_event_irq(struct irq_data *data) > >> > +{ > >> > + struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); > >> > + u32 mask, val; > >> > + > >> > + mask = plda_hwirq_to_mask(data->hwirq); > >> > + > >> > + raw_spin_lock(&port->lock); > >> > + val = readl_relaxed(port->bridge_addr + IMASK_LOCAL); > >> > + val |= mask; > >> > + writel_relaxed(val, port->bridge_addr + IMASK_LOCAL); > >> > + raw_spin_unlock(&port->lock); > >> > +} > >> > + > >> > +static struct irq_chip plda_event_irq_chip = { > >> > + .name = "PLDA PCIe EVENT", > >> > + .irq_ack = plda_ack_event_irq, > >> > + .irq_mask = plda_mask_event_irq, > >> > + .irq_unmask = plda_unmask_event_irq, > >> > +}; > >> > + > >> > static const struct plda_event_ops plda_event_ops = { > >> > .get_events = plda_get_events, > >> > }; > >> > @@ -778,7 +835,9 @@ static const struct plda_event_ops plda_event_ops = { > >> > static int plda_pcie_event_map(struct irq_domain *domain, unsigned int irq, > >> > irq_hw_number_t hwirq) > >> > { > >> > - irq_set_chip_and_handler(irq, &mc_event_irq_chip, handle_level_irq); > >> > + struct plda_pcie_rp *port = (void *)domain->host_data; > >> > + > >> > + irq_set_chip_and_handler(irq, port->event_irq_chip, handle_level_irq); > >> > irq_set_chip_data(irq, domain->host_data); > >> > > >> > return 0; > >> > @@ -963,6 +1022,9 @@ static int plda_init_interrupts(struct platform_device *pdev, > >> > if (!port->event_ops) > >> > port->event_ops = &plda_event_ops; > >> > > >> > + if (!port->event_irq_chip) > >> > + port->event_irq_chip = &plda_event_irq_chip; > >> > + > >> > ret = plda_pcie_init_irq_domains(port); > >> > if (ret) { > >> > dev_err(dev, "failed creating IRQ domains\n"); > >> > @@ -1040,6 +1102,7 @@ static int mc_platform_init(struct pci_config_window *cfg) > >> > return ret; > >> > > >> > port->plda.event_ops = &mc_event_ops; > >> > + port->plda.event_irq_chip = &mc_event_irq_chip; > >> > > >> > /* Address translation is up; safe to enable interrupts */ > >> > ret = plda_init_interrupts(pdev, &port->plda, &mc_event); > >> > diff --git a/drivers/pci/controller/plda/pcie-plda.h b/drivers/pci/controller/plda/pcie-plda.h > >> > index dd8bc2750bfc..24ac50c458dc 100644 > >> > --- a/drivers/pci/controller/plda/pcie-plda.h > >> > +++ b/drivers/pci/controller/plda/pcie-plda.h > >> > @@ -128,6 +128,8 @@ > >> > * DMA end : reserved for vendor implement > >> > */ > >> > > >> > +#define PM_MSI_TO_MASK_OFFSET 19 > >> > + > >> > struct plda_pcie_rp; > >> > > >> > struct plda_event_ops { > >> > @@ -150,6 +152,7 @@ struct plda_pcie_rp { > >> > raw_spinlock_t lock; > >> > struct plda_msi msi; > >> > const struct plda_event_ops *event_ops; > >> > + const struct irq_chip *event_irq_chip; > >> > void __iomem *bridge_addr; > >> > int num_events; > >> > };
On 2023/12/27 20:43, Lorenzo Pieralisi wrote: > [+Thomas] > > On Fri, Dec 22, 2023 at 07:18:48PM +0800, Minda Chen wrote: >> >> >> On 2023/12/21 23:32, Lorenzo Pieralisi wrote: >> > On Thu, Dec 21, 2023 at 06:56:22PM +0800, Minda Chen wrote: >> >> >> >> >> >> On 2023/12/14 15:28, Minda Chen wrote: >> >> > PolarFire PCIE event IRQs includes PLDA local interrupts and PolarFire >> >> > their own IRQs. PolarFire PCIe event irq_chip ops using an event_desc to >> >> > unify different IRQ register addresses. On PLDA sides, PLDA irqchip codes >> >> > only require to set PLDA local interrupt register. So the PLDA irqchip ops >> >> > codes can not be extracted from PolarFire codes. >> >> > >> >> > To support PLDA its own event IRQ process, implements PLDA irqchip ops and >> >> > add event irqchip field to struct pcie_plda_rp. >> >> > >> >> > Signed-off-by: Minda Chen <minda.chen@starfivetech.com> >> >> > --- >> >> > .../pci/controller/plda/pcie-microchip-host.c | 65 ++++++++++++++++++- >> >> > drivers/pci/controller/plda/pcie-plda.h | 3 + >> >> > 2 files changed, 67 insertions(+), 1 deletion(-) >> >> > >> >> Hi Conor >> >> Could you take time to review this patch? For I using event irq chip instead of event ops and the whole patch have been changed. I think it's better >> >> And I added the implementation of PLDA event irqchip and make it easier to claim the necessity of the modification. >> >> If you approve this, I will add back the review tag. Thanks >> >> >> >> Hi Lorenzo >> >> Have you reviewed this patch? Does the commit message and the codes are can be approved ?Thanks >> >> >> > >> > Please wrap the lines at 75 columns in length. >> > >> OK >> > I have not reviewed but I am still struggling to understand the >> > commit log, I apologise, I can try to review the series and figure >> > out what the patch is doing but I would appreciate if commits logs >> > could be made easier to parse. >> > >> > Thanks, >> > Lorenzo >> > >> >> The commit message it is not good. >> >> I draw a graph about the PCIe global event interrupt domain >> (related to patch 10- 16). >> Actually all these interrupts patches are for extracting the common >> PLDA codes to pcie-plda-host.c and do not change microchip's codes logic. > > s/codes/code (please apply this to the the full series) > > I will have a look at the code but I can't rewrite the commit log myself > (it does not scale I am afraid), as it stands I don't understand it and > that's a problem, I am sorry but that's important. > > I added Thomas (you should CC him for irqchip [only] changes) if he > has time to review these irqchip changes to make sure they are proper. > > Thanks, > Lorenzo > The interrupt irq_chip ops includes ack/mask/unmask. These ops are for writing the correct register. Microchip Implement their PCIe interrupts and require to write their registers. So the irq_chip ops are different. (List below are the microchip interrupt register base and status/mask register offset. In pcie-microchip-host.c:130) #define PCIE_EVENT(x) \ .base = MC_PCIE_CTRL_ADDR, \ .offset = PCIE_EVENT_INT, \ .mask_offset = PCIE_EVENT_INT, \ .mask_high = 1, \ .mask = PCIE_EVENT_INT_ ## x ## _INT, \ .enb_mask = PCIE_EVENT_INT_ENB_MASK #define SEC_EVENT(x) \ .base = MC_PCIE_CTRL_ADDR, \ .offset = SEC_ERROR_INT, \ .mask_offset = SEC_ERROR_INT_MASK, \ .mask = SEC_ERROR_INT_ ## x ## _INT, \ .mask_high = 1, \ .enb_mask = 0 #define DED_EVENT(x) \ .base = MC_PCIE_CTRL_ADDR, \ .offset = DED_ERROR_INT, \ .mask_offset = DED_ERROR_INT_MASK, \ .mask_high = 1, \ .mask = DED_ERROR_INT_ ## x ## _INT, \ .enb_mask = 0 >> +----------------------------------------------------------+ >> | microchip Global event interrupt domain | >> +-----------------------------------+-----------+----------+ >> | | microchip | PLDA | >> | | event num |(StarFive)| >> | | |event num | >> +-----------------------------------+-----------+----------+ >> | | 0 | | >> | | | | >> (mc pcie |microchip platform event interrupt | | | >> int line) | | | | >> ------------| | | | >> | |10 | | >> +-----------------------------------+-----------+----------+ >> | PLDA host DMA interrupt |11 | | >> | (int number is not fixed, defined | | | >> | by vendor) |14 | | >> +--+-----------------------------------+---------- +----------+-+ >> | | PLDA event interrupt |15 |0 | | >> | | (int number is fixed) | | | | >> ---------|--| | | | | >> (Starfive| | | | | | >> pcie int | | +------------------+ | | | | >> line) | | |INTx event domain | | | | | >> | | +------------------+ | | | | >> | | | | | | >> | | +------------------+ | | | | >> | | |MSI event domain | | | | | >> | | +------------------+ | | | | >> | | |27 |12 | | >> | +---------------------------------+-+-----------+----------+ | >> | extract PLDA event part to common PLDA file. | >> +---------------------------------------------------------------+ >> >> >> >> > diff --git a/drivers/pci/controller/plda/pcie-microchip-host.c b/drivers/pci/controller/plda/pcie-microchip-host.c >> >> > index fd0d92c3d03f..ff40c1622173 100644 >> >> > --- a/drivers/pci/controller/plda/pcie-microchip-host.c >> >> > +++ b/drivers/pci/controller/plda/pcie-microchip-host.c >> >> > @@ -771,6 +771,63 @@ static struct irq_chip mc_event_irq_chip = { >> >> > .irq_unmask = mc_unmask_event_irq, >> >> > }; >> >> > > +static u32 plda_hwirq_to_mask(int hwirq) >> >> > +{ >> >> > + u32 mask; >> >> > + >> >> > + if (hwirq < EVENT_PM_MSI_INT_INTX) >> >> > + mask = BIT(hwirq + A_ATR_EVT_POST_ERR_SHIFT); >> >> > + else if (hwirq == EVENT_PM_MSI_INT_INTX) >> >> > + mask = PM_MSI_INT_INTX_MASK; >> >> > + else >> >> > + mask = BIT(hwirq + PM_MSI_TO_MASK_OFFSET); >> >> > + >> >> > + return mask; >> >> > +} >> >> > + >> >> > +static void plda_ack_event_irq(struct irq_data *data) >> >> > +{ >> >> > + struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); >> >> > + >> >> > + writel_relaxed(plda_hwirq_to_mask(data->hwirq), >> >> > + port->bridge_addr + ISTATUS_LOCAL); >> >> > +} >> >> > + >> >> > +static void plda_mask_event_irq(struct irq_data *data) >> >> > +{ >> >> > + struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); >> >> > + u32 mask, val; >> >> > + >> >> > + mask = plda_hwirq_to_mask(data->hwirq); >> >> > + >> >> > + raw_spin_lock(&port->lock); >> >> > + val = readl_relaxed(port->bridge_addr + IMASK_LOCAL); >> >> > + val &= ~mask; >> >> > + writel_relaxed(val, port->bridge_addr + IMASK_LOCAL); >> >> > + raw_spin_unlock(&port->lock); >> >> > +} >> >> > + >> >> > +static void plda_unmask_event_irq(struct irq_data *data) >> >> > +{ >> >> > + struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); >> >> > + u32 mask, val; >> >> > + >> >> > + mask = plda_hwirq_to_mask(data->hwirq); >> >> > + >> >> > + raw_spin_lock(&port->lock); >> >> > + val = readl_relaxed(port->bridge_addr + IMASK_LOCAL); >> >> > + val |= mask; >> >> > + writel_relaxed(val, port->bridge_addr + IMASK_LOCAL); >> >> > + raw_spin_unlock(&port->lock); >> >> > +} >> >> > + >> >> > +static struct irq_chip plda_event_irq_chip = { >> >> > + .name = "PLDA PCIe EVENT", >> >> > + .irq_ack = plda_ack_event_irq, >> >> > + .irq_mask = plda_mask_event_irq, >> >> > + .irq_unmask = plda_unmask_event_irq, >> >> > +}; >> >> > + >> >> > static const struct plda_event_ops plda_event_ops = { >> >> > .get_events = plda_get_events, >> >> > }; >> >> > @@ -778,7 +835,9 @@ static const struct plda_event_ops plda_event_ops = { >> >> > static int plda_pcie_event_map(struct irq_domain *domain, unsigned int irq, >> >> > irq_hw_number_t hwirq) >> >> > { >> >> > - irq_set_chip_and_handler(irq, &mc_event_irq_chip, handle_level_irq); >> >> > + struct plda_pcie_rp *port = (void *)domain->host_data; >> >> > + >> >> > + irq_set_chip_and_handler(irq, port->event_irq_chip, handle_level_irq); >> >> > irq_set_chip_data(irq, domain->host_data); >> >> > >> >> > return 0; >> >> > @@ -963,6 +1022,9 @@ static int plda_init_interrupts(struct platform_device *pdev, >> >> > if (!port->event_ops) >> >> > port->event_ops = &plda_event_ops; >> >> > >> >> > + if (!port->event_irq_chip) >> >> > + port->event_irq_chip = &plda_event_irq_chip; >> >> > + >> >> > ret = plda_pcie_init_irq_domains(port); >> >> > if (ret) { >> >> > dev_err(dev, "failed creating IRQ domains\n"); >> >> > @@ -1040,6 +1102,7 @@ static int mc_platform_init(struct pci_config_window *cfg) >> >> > return ret; >> >> > >> >> > port->plda.event_ops = &mc_event_ops; >> >> > + port->plda.event_irq_chip = &mc_event_irq_chip; >> >> > >> >> > /* Address translation is up; safe to enable interrupts */ >> >> > ret = plda_init_interrupts(pdev, &port->plda, &mc_event); >> >> > diff --git a/drivers/pci/controller/plda/pcie-plda.h b/drivers/pci/controller/plda/pcie-plda.h >> >> > index dd8bc2750bfc..24ac50c458dc 100644 >> >> > --- a/drivers/pci/controller/plda/pcie-plda.h >> >> > +++ b/drivers/pci/controller/plda/pcie-plda.h >> >> > @@ -128,6 +128,8 @@ >> >> > * DMA end : reserved for vendor implement >> >> > */ >> >> > >> >> > +#define PM_MSI_TO_MASK_OFFSET 19 >> >> > + >> >> > struct plda_pcie_rp; >> >> > >> >> > struct plda_event_ops { >> >> > @@ -150,6 +152,7 @@ struct plda_pcie_rp { >> >> > raw_spinlock_t lock; >> >> > struct plda_msi msi; >> >> > const struct plda_event_ops *event_ops; >> >> > + const struct irq_chip *event_irq_chip; >> >> > void __iomem *bridge_addr; >> >> > int num_events; >> >> > };
diff --git a/drivers/pci/controller/plda/pcie-microchip-host.c b/drivers/pci/controller/plda/pcie-microchip-host.c index fd0d92c3d03f..ff40c1622173 100644 --- a/drivers/pci/controller/plda/pcie-microchip-host.c +++ b/drivers/pci/controller/plda/pcie-microchip-host.c @@ -771,6 +771,63 @@ static struct irq_chip mc_event_irq_chip = { .irq_unmask = mc_unmask_event_irq, }; +static u32 plda_hwirq_to_mask(int hwirq) +{ + u32 mask; + + if (hwirq < EVENT_PM_MSI_INT_INTX) + mask = BIT(hwirq + A_ATR_EVT_POST_ERR_SHIFT); + else if (hwirq == EVENT_PM_MSI_INT_INTX) + mask = PM_MSI_INT_INTX_MASK; + else + mask = BIT(hwirq + PM_MSI_TO_MASK_OFFSET); + + return mask; +} + +static void plda_ack_event_irq(struct irq_data *data) +{ + struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); + + writel_relaxed(plda_hwirq_to_mask(data->hwirq), + port->bridge_addr + ISTATUS_LOCAL); +} + +static void plda_mask_event_irq(struct irq_data *data) +{ + struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); + u32 mask, val; + + mask = plda_hwirq_to_mask(data->hwirq); + + raw_spin_lock(&port->lock); + val = readl_relaxed(port->bridge_addr + IMASK_LOCAL); + val &= ~mask; + writel_relaxed(val, port->bridge_addr + IMASK_LOCAL); + raw_spin_unlock(&port->lock); +} + +static void plda_unmask_event_irq(struct irq_data *data) +{ + struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); + u32 mask, val; + + mask = plda_hwirq_to_mask(data->hwirq); + + raw_spin_lock(&port->lock); + val = readl_relaxed(port->bridge_addr + IMASK_LOCAL); + val |= mask; + writel_relaxed(val, port->bridge_addr + IMASK_LOCAL); + raw_spin_unlock(&port->lock); +} + +static struct irq_chip plda_event_irq_chip = { + .name = "PLDA PCIe EVENT", + .irq_ack = plda_ack_event_irq, + .irq_mask = plda_mask_event_irq, + .irq_unmask = plda_unmask_event_irq, +}; + static const struct plda_event_ops plda_event_ops = { .get_events = plda_get_events, }; @@ -778,7 +835,9 @@ static const struct plda_event_ops plda_event_ops = { static int plda_pcie_event_map(struct irq_domain *domain, unsigned int irq, irq_hw_number_t hwirq) { - irq_set_chip_and_handler(irq, &mc_event_irq_chip, handle_level_irq); + struct plda_pcie_rp *port = (void *)domain->host_data; + + irq_set_chip_and_handler(irq, port->event_irq_chip, handle_level_irq); irq_set_chip_data(irq, domain->host_data); return 0; @@ -963,6 +1022,9 @@ static int plda_init_interrupts(struct platform_device *pdev, if (!port->event_ops) port->event_ops = &plda_event_ops; + if (!port->event_irq_chip) + port->event_irq_chip = &plda_event_irq_chip; + ret = plda_pcie_init_irq_domains(port); if (ret) { dev_err(dev, "failed creating IRQ domains\n"); @@ -1040,6 +1102,7 @@ static int mc_platform_init(struct pci_config_window *cfg) return ret; port->plda.event_ops = &mc_event_ops; + port->plda.event_irq_chip = &mc_event_irq_chip; /* Address translation is up; safe to enable interrupts */ ret = plda_init_interrupts(pdev, &port->plda, &mc_event); diff --git a/drivers/pci/controller/plda/pcie-plda.h b/drivers/pci/controller/plda/pcie-plda.h index dd8bc2750bfc..24ac50c458dc 100644 --- a/drivers/pci/controller/plda/pcie-plda.h +++ b/drivers/pci/controller/plda/pcie-plda.h @@ -128,6 +128,8 @@ * DMA end : reserved for vendor implement */ +#define PM_MSI_TO_MASK_OFFSET 19 + struct plda_pcie_rp; struct plda_event_ops { @@ -150,6 +152,7 @@ struct plda_pcie_rp { raw_spinlock_t lock; struct plda_msi msi; const struct plda_event_ops *event_ops; + const struct irq_chip *event_irq_chip; void __iomem *bridge_addr; int num_events; };