Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp131819rdh; Wed, 25 Oct 2023 19:23:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG6quu+pEc1w+PcOnn2tUWekhGnUU8rxTgTOO6Z7KdW6NTRxWTp5YKtZFAMce/7oMAupRc3 X-Received: by 2002:a05:620a:2620:b0:777:74b9:219f with SMTP id z32-20020a05620a262000b0077774b9219fmr17698359qko.8.1698286995902; Wed, 25 Oct 2023 19:23:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698286995; cv=none; d=google.com; s=arc-20160816; b=a+iX0IWTS1yHQjdjVjVvRVKAK0YdMgqi8r+bpkkVTl6vrPMcfztkqtDb95XkifBPv6 +R7drc6e8DqBxEXaXMpZm9bxwwwdLCSkobRSugbK0pL2+AJjG7PFATkXcZOhTAbhZF5C FpshakUivaWvOP+6WsY7QIa2uEDUE8eGRKtBOMaZbxNQdoNxcayC0gRGJzUjHz5Wfw0R HuIeeDiT2mNTmapO/BIvYVjOYdktx1j+Y8Vh/EpHFetMhuiSGRhY9QLk7daWr6d4LBX0 +8HCbVD76LX+IE7M77z0DEIkipEPw7hTFGZeAb7YqOlsDzxzXggUyjP4j9BA1UkDzKrD MNCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=MmUYcxwstMnNcTn5r9wL49ZNzk0zMbUyNnWbZTDz564=; fh=DQuCX7JsgkC5aftTtk2+5Jq/iyvcEVd4XbCyiXLxSNM=; b=m3SNUb7lj0aBcQjynaou+BUPUd1KBEhqvW6RKKOeqKN7V9IxRHgz0yZbQQYlYDvhWg OPf96OL+vBnh4Zf1DvEDbUXDQ7YttriCCgREhHRoHIx88c7IddCBeLd/vbGnPYmf/C5Q vCmz8Oq5B4IllT6/FjGu0wr+ebkW98ip3WKeNGy1tqgHpSB+geaoZ/MBpu4Oe3VMx3N0 5V7KP/BL33mDOsChL7kVaVNN+kL4NdgCZTDBElr9Jq8Ni3JF2aT5p2m9ZvwuE169gXSg QQdcHC2BX9rkzyT/C14057mlVtZNeuTP3kIsH83XNoELaRkmGN4W1BgV+cDyRq7JeIvt 1TYA== 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:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id g14-20020a25b10e000000b00da07267941fsi4448766ybj.253.2023.10.25.19.23.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 19:23:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (Postfix) with ESMTP id 7DDF980EBCB0; Wed, 25 Oct 2023 19:23:12 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343699AbjJZCXB (ORCPT + 99 others); Wed, 25 Oct 2023 22:23:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229748AbjJZCXA (ORCPT ); Wed, 25 Oct 2023 22:23:00 -0400 Received: from ex01.ufhost.com (ex01.ufhost.com [61.152.239.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD892AC; Wed, 25 Oct 2023 19:22:56 -0700 (PDT) Received: from EXMBX166.cuchost.com (unknown [175.102.18.54]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "EXMBX166", Issuer "EXMBX166" (not verified)) by ex01.ufhost.com (Postfix) with ESMTP id E873824DBFD; Thu, 26 Oct 2023 10:22:35 +0800 (CST) Received: from EXMBX171.cuchost.com (172.16.6.91) by EXMBX166.cuchost.com (172.16.6.76) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Thu, 26 Oct 2023 10:22:35 +0800 Received: from [192.168.125.85] (183.27.99.126) by EXMBX171.cuchost.com (172.16.6.91) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Thu, 26 Oct 2023 10:22:34 +0800 Message-ID: <09f8a530-1bd0-4dc3-85a2-8d67fdcd0148@starfivetech.com> Date: Thu, 26 Oct 2023 10:22:34 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v9 14/20] PCI: microchip: Add get_events() callback function Content-Language: en-US To: Conor Dooley CC: =?UTF-8?Q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Daire McNamara , "Emil Renner Berthing" , Krzysztof Kozlowski , , , , , Paul Walmsley , "Palmer Dabbelt" , Albert Ou , "Philipp Zabel" , Mason Huo , Leyfoon Tan , Kevin Xie References: <20231020104341.63157-1-minda.chen@starfivetech.com> <20231020104341.63157-15-minda.chen@starfivetech.com> <20231025-lizard-prideful-5223384b2c27@spud> From: Minda Chen In-Reply-To: <20231025-lizard-prideful-5223384b2c27@spud> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [183.27.99.126] X-ClientProxiedBy: EXCAS066.cuchost.com (172.16.6.26) 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 howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 25 Oct 2023 19:23:12 -0700 (PDT) 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 >> Acked-by: Conor Dooley >> --- >> 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 >>