From patchwork Fri Sep 15 10:22:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 140340 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp943974vqi; Fri, 15 Sep 2023 03:34:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG2eP+kOBy9n9T6SCmebAWrB8V7VjhLDwCrnivn2toYYA052kyi/sRzoEWSTJC0qgm3lI4t X-Received: by 2002:a17:902:6b0a:b0:1c1:e5f7:a743 with SMTP id o10-20020a1709026b0a00b001c1e5f7a743mr1196459plk.55.1694774053456; Fri, 15 Sep 2023 03:34:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694774053; cv=none; d=google.com; s=arc-20160816; b=h2PTORx6MBC65xAvHTBlub6gs9LcpecBttJ+UToXE080/TQ10Sosq7JmC+nDiwuFiN NpDnpoTSh0GE+LfOasmHx9sahSEKrC1CO+2br/A6ZAg5vBzjTPkxVYlH9wO3qoTDsjQU MAAnbCqqcSZ9eOMKo8KCgtNk+D3MADUddouW/6rW1aLdWPDeKR/pPbUtugISXnFhzrH1 OyN/RkwSrMjOgO8bRrjJ9eaMMMLZstrlgKiTOrsiJt2RYrV3fK/TmVVJPyzcATUmzOwF +ENKInyLbL7C07F3Rc1imeGThloUA6XQA/xKWw3QjpZ4v78qo+GgSufhqvcC/towoY5n l83w== 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=Iq8pSdAWDyYTwYPKpg7sd5FHO97Z+sLA9YpJBMZnGAU=; fh=y8d0C5dLtGb8zs8KQUIJy2R9+5DBPV29N8a8eZxYvuU=; b=R9czrCB1GNwt/AElrjDze/MfVywUWzbBvK728ctQ2ELMvK01r+ZEvEvBcfmhQWR1yf 7LClcQZqzH1QD+qJv2DkD3VvOepNB4kelmuK5PH4Ur9qKHyFUE9RQqCEAfWrh69upGto aJwWbyfbZ9YUWoOW2eQwMYdnA+w9Ms2HLrg64GZMEKkBa0QrGwPkMT7CIPc4+zxIdfw9 qfNd1MM2muf1bEfoCsscILsmlGpJV6iWwEJLJGR+GCWRXI6GcosZmrULKOwgqzY3uQYM WtHWKljTImOUmkguzRbb6ZPvVozijTC035Byn7oMJSdvEIqfhpPaC7jEEfQNIIinr2Xl 5KEg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id i1-20020a170902cf0100b001a6f0eab385si3262609plg.55.2023.09.15.03.34.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 03:34:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 A957B88D6A39; Fri, 15 Sep 2023 03:23:40 -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 S234470AbjIOKXd (ORCPT + 32 others); Fri, 15 Sep 2023 06:23:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234306AbjIOKXD (ORCPT ); Fri, 15 Sep 2023 06:23:03 -0400 Received: from fd01.gateway.ufhost.com (fd01.gateway.ufhost.com [61.152.239.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8664A1; Fri, 15 Sep 2023 03:22:58 -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 fd01.gateway.ufhost.com (Postfix) with ESMTP id 6E9DE85C3; Fri, 15 Sep 2023 18:22:57 +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; Fri, 15 Sep 2023 18:22:57 +0800 Received: from ubuntu.localdomain (113.72.144.67) by EXMBX171.cuchost.com (172.16.6.91) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Fri, 15 Sep 2023 18:22:55 +0800 From: Minda Chen To: Daire McNamara , Conor Dooley , Rob Herring , Krzysztof Kozlowski , Bjorn Helgaas , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Emil Renner Berthing CC: , , , , =?utf-8?q?P?= =?utf-8?q?ali_Roh=C3=A1r?= , Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Mason Huo , Leyfoon Tan , Kevin Xie , Minda Chen Subject: [PATCH v6 13/19] PCI: microchip: Add get_events() callback function Date: Fri, 15 Sep 2023 18:22:37 +0800 Message-ID: <20230915102243.59775-14-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230915102243.59775-1-minda.chen@starfivetech.com> References: <20230915102243.59775-1-minda.chen@starfivetech.com> MIME-Version: 1.0 X-Originating-IP: [113.72.144.67] 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=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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]); Fri, 15 Sep 2023 03:23:40 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777099398151673943 X-GMAIL-MSGID: 1777099398151673943 For different interrupts to event num mapping function, add get_events() function pointer. Also add struct plda_event_ops for extent ops in the fucture. Signed-off-by: Minda Chen --- drivers/pci/controller/plda/pcie-microchip-host.c | 14 +++++++++++++- drivers/pci/controller/plda/pcie-plda.h | 2 ++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/pci/controller/plda/pcie-microchip-host.c b/drivers/pci/controller/plda/pcie-microchip-host.c index fb09b6c34e01..875bdb03ce22 100644 --- a/drivers/pci/controller/plda/pcie-microchip-host.c +++ b/drivers/pci/controller/plda/pcie-microchip-host.c @@ -646,7 +646,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); @@ -805,7 +805,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, @@ -919,6 +924,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"); @@ -929,6 +939,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 af5e69718342..48d7bc471137 100644 --- a/drivers/pci/controller/plda/pcie-plda.h +++ b/drivers/pci/controller/plda/pcie-plda.h @@ -149,11 +149,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;