Message ID | 20231020104341.63157-15-minda.chen@starfivetech.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp963508vqb; Fri, 20 Oct 2023 03:45:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHOFnFwmmTd0nM3bH2OG2RLHDkj2BXEbbYnjvCyyPLhuMlJRYCj3TWjclRgl64CDhKVM8+h X-Received: by 2002:a17:903:1cf:b0:1b9:e972:134d with SMTP id e15-20020a17090301cf00b001b9e972134dmr1534159plh.3.1697798730689; Fri, 20 Oct 2023 03:45:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697798730; cv=none; d=google.com; s=arc-20160816; b=w9zNk1yB5heaXRWDsvG7syQ5a1yNpqxzf9BRWKeQ/ECRGEz8P5LjsA+kw071kPsITm z8fICOlQwGxEaWtidyZ0e0rHtq10XZPwCrLWkZJ1jcfMvj8B2MfmWJkpBYPLORyW4g9z YiTG/nwSDMcSWNcS+RNaOzyyYHMlgJ4bxXJ7e/lCT7xfW8VeptWuYgAYXn8E14Fudnhx FoNigHp7fFbcPoq5olYgcysMhDqXoWNVqt9bfo762hdh/bp/vCean6IMv9GxqTfvDlyv gtrEzmUitoSe86sRbJ3+G53R2Ca2WcV5u7CsopbHWMkQq9MFkbJGpFbOZUwXIRcwV67u 5kmw== 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=WE3PvEY49E7xMbbpB/nbpmdQTojLx+MBDpTBwHkwWiQ=; fh=ld3UXb1S5Y4IkunPfuj6e9Ppmc+fy6ncC+eQtrVLfK8=; b=Ov6Ah9CIp2hMvtEx9Vm2D4Hzu6OBmknAyAKzMaE0DNPTdcHYRG0UoJdMbIF6BnXlA+ AE1EJ9WXDNS2wO71dXQpXkGA4UgCNXpmZIs3ODtQpp0jDKjR1HOIIpnUdr63/VNR8MiH XLEgnY/TcVkEJxftIM98XacYBzILoirSkNxfyB5v9bg2sFyxWe617MUQG5d4p5DKVBeF 8+KaWqDHutlLLSmQowwLDrjv5HIGEJwDhvZT2DV+Ip9V+RTPL1d5k/wR8aK8FCt959Qu xb/NDbj6Bm6w+v8BMh/XvFgceJQS3CcS5i+XOySX33b9539+QAem/mSUUQEXYNnxbmT3 zXsw== 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:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id w6-20020a170902d3c600b001ca33ce21fesi1514206plb.58.2023.10.20.03.45.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 03:45:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (Postfix) with ESMTP id 81161807CCBE; Fri, 20 Oct 2023 03:45:27 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377103AbjJTKoj (ORCPT <rfc822;lkml4gm@gmail.com> + 25 others); Fri, 20 Oct 2023 06:44:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377065AbjJTKn6 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 20 Oct 2023 06:43:58 -0400 Received: from fd01.gateway.ufhost.com (fd01.gateway.ufhost.com [61.152.239.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43E829F; Fri, 20 Oct 2023 03:43:56 -0700 (PDT) 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 fd01.gateway.ufhost.com (Postfix) with ESMTP id 03E9F808F; Fri, 20 Oct 2023 18:43:55 +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; Fri, 20 Oct 2023 18:43:55 +0800 Received: from ubuntu.localdomain (183.27.99.123) by EXMBX171.cuchost.com (172.16.6.91) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Fri, 20 Oct 2023 18:43:53 +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 v9 14/20] PCI: microchip: Add get_events() callback function Date: Fri, 20 Oct 2023 18:43:35 +0800 Message-ID: <20231020104341.63157-15-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20231020104341.63157-1-minda.chen@starfivetech.com> References: <20231020104341.63157-1-minda.chen@starfivetech.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [183.27.99.123] X-ClientProxiedBy: EXCAS062.cuchost.com (172.16.6.22) 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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.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 (morse.vger.email [0.0.0.0]); Fri, 20 Oct 2023 03:45:27 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780271001726287929 X-GMAIL-MSGID: 1780271001726287929 |
Series |
Refactoring Microchip PCIe driver and add StarFive PCIe
|
|
Commit Message
Minda Chen
Oct. 20, 2023, 10:43 a.m. UTC
PolarFire implements their own PCIe interrupts, which added to global PCIe field for PLDA lack of MSI controller, the interrupts to event num mapping is different to PLDA local interrupts. So add get_events() function pointer. Also add struct plda_event_ops function pointer structure to struct plda_pcie_rp. plda_handle_events() will call the get_events() callback function pointer directly. For the robustness of codes, add checking in plda_init_interrupts(). Signed-off-by: Minda Chen <minda.chen@starfivetech.com> Acked-by: Conor Dooley <conor.dooley@microchip.com> --- drivers/pci/controller/plda/pcie-microchip-host.c | 14 +++++++++++++- drivers/pci/controller/plda/pcie-plda.h | 8 ++++++++ 2 files changed, 21 insertions(+), 1 deletion(-)
Comments
Hey, On Fri, Oct 20, 2023 at 06:43:35PM +0800, Minda Chen wrote: > PolarFire implements their own PCIe interrupts, > which added to global PCIe field for PLDA lack of > MSI controller, the interrupts to event num mapping > is different to PLDA local interrupts. So add > get_events() function pointer. Just FYI, it's not the PLDA IP's lack of an MSI controller, it's the SoC itself that doesn't have one. Last time I spoke to Daire about this, he was surprised that you didn't need something similar. I might reword this as "PolarFire SoC implements its own PCIe interrupts, additional to the regular PCIe interrupts, due to the lack of an MSI controller, so the interrupt to event number mapping is different to the PLDA local interrupts, necessitating a custom get_events() implementation." > Also add struct plda_event_ops function pointer structure > to struct plda_pcie_rp. I'd probably also drop this, as it is evident from the diff. Cheers, Conor. > plda_handle_events() will call the get_events() callback > function pointer directly. For the robustness of codes, > add checking in plda_init_interrupts(). > > Signed-off-by: Minda Chen <minda.chen@starfivetech.com> > Acked-by: Conor Dooley <conor.dooley@microchip.com> > --- > drivers/pci/controller/plda/pcie-microchip-host.c | 14 +++++++++++++- > drivers/pci/controller/plda/pcie-plda.h | 8 ++++++++ > 2 files changed, 21 insertions(+), 1 deletion(-) > > diff --git a/drivers/pci/controller/plda/pcie-microchip-host.c b/drivers/pci/controller/plda/pcie-microchip-host.c > index e57827bdb4b3..5a8c134bf643 100644 > --- a/drivers/pci/controller/plda/pcie-microchip-host.c > +++ b/drivers/pci/controller/plda/pcie-microchip-host.c > @@ -652,7 +652,7 @@ static void plda_handle_event(struct irq_desc *desc) > > chained_irq_enter(chip, desc); > > - events = mc_get_events(port); > + events = port->event_ops->get_events(port); > > for_each_set_bit(bit, &events, port->num_events) > generic_handle_domain_irq(port->event_domain, bit); > @@ -811,7 +811,12 @@ static int mc_request_event_irq(struct plda_pcie_rp *plda, int event_irq, > 0, event_cause[event].sym, plda); > } > > +static const struct plda_event_ops mc_event_ops = { > + .get_events = mc_get_events, > +}; > + > static const struct plda_event mc_event = { > + .event_ops = &mc_event_ops, > .request_event_irq = mc_request_event_irq, > .intx_event = EVENT_LOCAL_PM_MSI_INT_INTX, > .msi_event = EVENT_LOCAL_PM_MSI_INT_MSI, > @@ -925,6 +930,11 @@ static int plda_init_interrupts(struct platform_device *pdev, > int i, intx_irq, msi_irq, event_irq; > int ret; > > + if (!event->event_ops || !event->event_ops->get_events) { > + dev_err(dev, "no get events ops\n"); > + return -EINVAL; > + } > + > ret = plda_pcie_init_irq_domains(port); > if (ret) { > dev_err(dev, "failed creating IRQ domains\n"); > @@ -935,6 +945,8 @@ static int plda_init_interrupts(struct platform_device *pdev, > if (irq < 0) > return -ENODEV; > > + port->event_ops = event->event_ops; > + > for (i = 0; i < port->num_events; i++) { > event_irq = irq_create_mapping(port->event_domain, i); > if (!event_irq) { > diff --git a/drivers/pci/controller/plda/pcie-plda.h b/drivers/pci/controller/plda/pcie-plda.h > index fba7343f9a96..df1729095952 100644 > --- a/drivers/pci/controller/plda/pcie-plda.h > +++ b/drivers/pci/controller/plda/pcie-plda.h > @@ -102,6 +102,12 @@ > #define EVENT_PM_MSI_INT_SYS_ERR 12 > #define NUM_PLDA_EVENTS 13 > > +struct plda_pcie_rp; > + > +struct plda_event_ops { > + u32 (*get_events)(struct plda_pcie_rp *pcie); > +}; > + > struct plda_msi { > struct mutex lock; /* Protect used bitmap */ > struct irq_domain *msi_domain; > @@ -117,11 +123,13 @@ struct plda_pcie_rp { > struct irq_domain *event_domain; > raw_spinlock_t lock; > struct plda_msi msi; > + const struct plda_event_ops *event_ops; > void __iomem *bridge_addr; > int num_events; > }; > > struct plda_event { > + const struct plda_event_ops *event_ops; > int (*request_event_irq)(struct plda_pcie_rp *pcie, > int event_irq, int event); > int intx_event; > -- > 2.17.1 >
On 2023/10/25 18:44, Conor Dooley wrote: > Hey, > > On Fri, Oct 20, 2023 at 06:43:35PM +0800, Minda Chen wrote: >> PolarFire implements their own PCIe interrupts, >> which added to global PCIe field for PLDA lack of >> MSI controller, the interrupts to event num mapping >> is different to PLDA local interrupts. So add >> get_events() function pointer. > > Just FYI, it's not the PLDA IP's lack of an MSI controller, it's the SoC > itself that doesn't have one. Last time I spoke to Daire about this, he > was surprised that you didn't need something similar. I might reword > this as > > "PolarFire SoC implements its own PCIe interrupts, additional to the > regular PCIe interrupts, due to the lack of an MSI controller, so the > interrupt to event number mapping is different to the PLDA local > interrupts, necessitating a custom get_events() implementation." > >> Also add struct plda_event_ops function pointer structure >> to struct plda_pcie_rp. > > I'd probably also drop this, as it is evident from the diff. > > Cheers, > Conor. > OK. Thanks very much. >> plda_handle_events() will call the get_events() callback >> function pointer directly. For the robustness of codes, >> add checking in plda_init_interrupts(). >> >> Signed-off-by: Minda Chen <minda.chen@starfivetech.com> >> Acked-by: Conor Dooley <conor.dooley@microchip.com> >> --- >> drivers/pci/controller/plda/pcie-microchip-host.c | 14 +++++++++++++- >> drivers/pci/controller/plda/pcie-plda.h | 8 ++++++++ >> 2 files changed, 21 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/pci/controller/plda/pcie-microchip-host.c b/drivers/pci/controller/plda/pcie-microchip-host.c >> index e57827bdb4b3..5a8c134bf643 100644 >> --- a/drivers/pci/controller/plda/pcie-microchip-host.c >> +++ b/drivers/pci/controller/plda/pcie-microchip-host.c >> @@ -652,7 +652,7 @@ static void plda_handle_event(struct irq_desc *desc) >> >> chained_irq_enter(chip, desc); >> >> - events = mc_get_events(port); >> + events = port->event_ops->get_events(port); >> >> for_each_set_bit(bit, &events, port->num_events) >> generic_handle_domain_irq(port->event_domain, bit); >> @@ -811,7 +811,12 @@ static int mc_request_event_irq(struct plda_pcie_rp *plda, int event_irq, >> 0, event_cause[event].sym, plda); >> } >> >> +static const struct plda_event_ops mc_event_ops = { >> + .get_events = mc_get_events, >> +}; >> + >> static const struct plda_event mc_event = { >> + .event_ops = &mc_event_ops, >> .request_event_irq = mc_request_event_irq, >> .intx_event = EVENT_LOCAL_PM_MSI_INT_INTX, >> .msi_event = EVENT_LOCAL_PM_MSI_INT_MSI, >> @@ -925,6 +930,11 @@ static int plda_init_interrupts(struct platform_device *pdev, >> int i, intx_irq, msi_irq, event_irq; >> int ret; >> >> + if (!event->event_ops || !event->event_ops->get_events) { >> + dev_err(dev, "no get events ops\n"); >> + return -EINVAL; >> + } >> + >> ret = plda_pcie_init_irq_domains(port); >> if (ret) { >> dev_err(dev, "failed creating IRQ domains\n"); >> @@ -935,6 +945,8 @@ static int plda_init_interrupts(struct platform_device *pdev, >> if (irq < 0) >> return -ENODEV; >> >> + port->event_ops = event->event_ops; >> + >> for (i = 0; i < port->num_events; i++) { >> event_irq = irq_create_mapping(port->event_domain, i); >> if (!event_irq) { >> diff --git a/drivers/pci/controller/plda/pcie-plda.h b/drivers/pci/controller/plda/pcie-plda.h >> index fba7343f9a96..df1729095952 100644 >> --- a/drivers/pci/controller/plda/pcie-plda.h >> +++ b/drivers/pci/controller/plda/pcie-plda.h >> @@ -102,6 +102,12 @@ >> #define EVENT_PM_MSI_INT_SYS_ERR 12 >> #define NUM_PLDA_EVENTS 13 >> >> +struct plda_pcie_rp; >> + >> +struct plda_event_ops { >> + u32 (*get_events)(struct plda_pcie_rp *pcie); >> +}; >> + >> struct plda_msi { >> struct mutex lock; /* Protect used bitmap */ >> struct irq_domain *msi_domain; >> @@ -117,11 +123,13 @@ struct plda_pcie_rp { >> struct irq_domain *event_domain; >> raw_spinlock_t lock; >> struct plda_msi msi; >> + const struct plda_event_ops *event_ops; >> void __iomem *bridge_addr; >> int num_events; >> }; >> >> struct plda_event { >> + const struct plda_event_ops *event_ops; >> int (*request_event_irq)(struct plda_pcie_rp *pcie, >> int event_irq, int event); >> int intx_event; >> -- >> 2.17.1 >>
diff --git a/drivers/pci/controller/plda/pcie-microchip-host.c b/drivers/pci/controller/plda/pcie-microchip-host.c index e57827bdb4b3..5a8c134bf643 100644 --- a/drivers/pci/controller/plda/pcie-microchip-host.c +++ b/drivers/pci/controller/plda/pcie-microchip-host.c @@ -652,7 +652,7 @@ static void plda_handle_event(struct irq_desc *desc) chained_irq_enter(chip, desc); - events = mc_get_events(port); + events = port->event_ops->get_events(port); for_each_set_bit(bit, &events, port->num_events) generic_handle_domain_irq(port->event_domain, bit); @@ -811,7 +811,12 @@ static int mc_request_event_irq(struct plda_pcie_rp *plda, int event_irq, 0, event_cause[event].sym, plda); } +static const struct plda_event_ops mc_event_ops = { + .get_events = mc_get_events, +}; + static const struct plda_event mc_event = { + .event_ops = &mc_event_ops, .request_event_irq = mc_request_event_irq, .intx_event = EVENT_LOCAL_PM_MSI_INT_INTX, .msi_event = EVENT_LOCAL_PM_MSI_INT_MSI, @@ -925,6 +930,11 @@ static int plda_init_interrupts(struct platform_device *pdev, int i, intx_irq, msi_irq, event_irq; int ret; + if (!event->event_ops || !event->event_ops->get_events) { + dev_err(dev, "no get events ops\n"); + return -EINVAL; + } + ret = plda_pcie_init_irq_domains(port); if (ret) { dev_err(dev, "failed creating IRQ domains\n"); @@ -935,6 +945,8 @@ static int plda_init_interrupts(struct platform_device *pdev, if (irq < 0) return -ENODEV; + port->event_ops = event->event_ops; + for (i = 0; i < port->num_events; i++) { event_irq = irq_create_mapping(port->event_domain, i); if (!event_irq) { diff --git a/drivers/pci/controller/plda/pcie-plda.h b/drivers/pci/controller/plda/pcie-plda.h index fba7343f9a96..df1729095952 100644 --- a/drivers/pci/controller/plda/pcie-plda.h +++ b/drivers/pci/controller/plda/pcie-plda.h @@ -102,6 +102,12 @@ #define EVENT_PM_MSI_INT_SYS_ERR 12 #define NUM_PLDA_EVENTS 13 +struct plda_pcie_rp; + +struct plda_event_ops { + u32 (*get_events)(struct plda_pcie_rp *pcie); +}; + struct plda_msi { struct mutex lock; /* Protect used bitmap */ struct irq_domain *msi_domain; @@ -117,11 +123,13 @@ struct plda_pcie_rp { struct irq_domain *event_domain; raw_spinlock_t lock; struct plda_msi msi; + const struct plda_event_ops *event_ops; void __iomem *bridge_addr; int num_events; }; struct plda_event { + const struct plda_event_ops *event_ops; int (*request_event_irq)(struct plda_pcie_rp *pcie, int event_irq, int event); int intx_event;