Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp1004655rdh; Fri, 27 Oct 2023 01:44:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHaBJI48dTSPr7Xi940dkZH8Xk9NZnd9Pm8k1UXHbUP4nU50/TygQ00T7so0UUF2EqM7zD9 X-Received: by 2002:a67:e1c5:0:b0:45a:de9b:8d44 with SMTP id p5-20020a67e1c5000000b0045ade9b8d44mr2136388vsl.3.1698396251387; Fri, 27 Oct 2023 01:44:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698396251; cv=none; d=google.com; s=arc-20160816; b=JHpeE9wy+rh3ZfuDH0w5HWzbVSfYDPabLMovAMDbpIro9PfVhRNAFIPeQPgD9+6dh0 hfIW77VtZZJr8MUUtG07t8IChylfonOtH8naXJNjDRae4iqVBxSgrw98c5J5Z7kjYuC1 bKrnMo2S7MLruIkzOvvOlIGnfXA8SrSkmbydjOA5UsR52lKbxQHNNYmg8ILslbTdolMw fFzK0LBd77XTSUOxiamqmOAr+9j30oLSi6yrSBG52gpv7s/xv3qSBHZqg5g3C5VHfF0s bugPDF5vIPytdoY0mnSh8lMSKh52CFuFVeWYpaVmW35Pvx9vRo0u9t5nJUnZhSG3i9Qy sQmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=WGO6hjkMHMtX7U62PjVv9kWlUZJFjcfJsN4vTr8Xu5o=; fh=7oMcwTf5aH7qgW/yZBn3JB50MzGGamyn87tkNm7YvQ4=; b=lrzV+DfRYMeE9Du+z/Z1MszqbX8wFECjNCbN5k6JemoHWKRD+4LGol5ELdf9ehbT+Q EEZQt4/rfnHKXVkJZcJg6W0HqIlu52cOgHIKGZi+VX5SNUhRs9teRfiCjnVQzcvHmCTW uChJOIvK2nkr7++sNkaqHuzFtUsjroQru4orsQg1XrLXr2zh96x1oSuPQc7FU1RZY2d4 IBTaiJfKuaBVsZwPEFCoNlIAolhv7hx63S128lHan8+8TzfruLO35uNm/Z0DlKmS5+m3 LuIs7lpOsVLDkqo55y4VZXWvr0pLas89rN7xuMgUJO2u5EWCKeTFOLV8c+BVUFtqFhUX /HKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=gvdGeey7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id e207-20020a2537d8000000b00da09e0aff67si1884204yba.389.2023.10.27.01.44.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Oct 2023 01:44:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=gvdGeey7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 0CCE2837848E; Fri, 27 Oct 2023 01:44:08 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345665AbjJ0Inq (ORCPT + 99 others); Fri, 27 Oct 2023 04:43:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235105AbjJ0Inb (ORCPT ); Fri, 27 Oct 2023 04:43:31 -0400 Received: from lelv0142.ext.ti.com (lelv0142.ext.ti.com [198.47.23.249]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4DBD61BCC; Fri, 27 Oct 2023 01:42:26 -0700 (PDT) Received: from lelv0265.itg.ti.com ([10.180.67.224]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 39R8g4WH124179; Fri, 27 Oct 2023 03:42:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1698396124; bh=WGO6hjkMHMtX7U62PjVv9kWlUZJFjcfJsN4vTr8Xu5o=; h=From:To:CC:Subject:Date; b=gvdGeey7NVse+nim+ro0tvPZy5DGZBMZlL4eFZPT8yUdStQJjEHd7myi6UlzhVX/P 2nZBkiP1PbvIrTsiEAvcYA9sNlMPB66jcLUQxJLVGCDPGnbDsggJ+ARoc9r//3V3eg UTmWgRDlC5q3AupyNUJ2dfgSVYGk/m8oJMPFzhS0= Received: from DLEE112.ent.ti.com (dlee112.ent.ti.com [157.170.170.23]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 39R8g4i9004917 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 27 Oct 2023 03:42:04 -0500 Received: from DLEE115.ent.ti.com (157.170.170.26) by DLEE112.ent.ti.com (157.170.170.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Fri, 27 Oct 2023 03:42:04 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DLEE115.ent.ti.com (157.170.170.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Fri, 27 Oct 2023 03:42:04 -0500 Received: from uda0492258.dhcp.ti.com (ileaxei01-snat.itg.ti.com [10.180.69.5]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id 39R8fxTB012713; Fri, 27 Oct 2023 03:42:00 -0500 From: Siddharth Vadapalli To: , , , , CC: , , , , , , , Subject: [RFC PATCH] PCI: keystone: Refactor ks_pcie_v3_65_add_bus() functionality Date: Fri, 27 Oct 2023 14:11:59 +0530 Message-ID: <20231027084159.4166188-1-s-vadapalli@ti.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 fry.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 (fry.vger.email [0.0.0.0]); Fri, 27 Oct 2023 01:44:08 -0700 (PDT) The .add_bus() callback "ks_pcie_v3_65_add_bus()" exists to setup BAR0 for MSI configuration. This method is expected to be invoked after the enumeration of endpoints for the v3.65a DWC PCIe IP Controller. Based on the discussion at [0], the contents of "ks_pcie_v3_65_add_bus()" can be moved to the .host_init callback "ks_pcie_host_init()" and the .add_bus callback within "struct pci_ops ks_pcie_ops" is no longer required. Hence, for the v3.65a DWC PCIe IP Controllers (!ks_pcie->is_am6), perform the MSI specific configuration of BAR0 within "ks_pcie_host_init()" itself. [0] https://lore.kernel.org/r/20231019220847.GA1413474@bhelgaas/ Suggested-by: Serge Semin Suggested-by: Bjorn Helgaas Signed-off-by: Siddharth Vadapalli --- Hello, This patch is based on linux-next tagged next-20231027. This patch depends on the patch at: https://lore.kernel.org/r/20231019081330.2975470-1-s-vadapalli@ti.com/ Regards, Siddharth. drivers/pci/controller/dwc/pci-keystone.c | 51 ++++++++--------------- 1 file changed, 17 insertions(+), 34 deletions(-) diff --git a/drivers/pci/controller/dwc/pci-keystone.c b/drivers/pci/controller/dwc/pci-keystone.c index e9245b7632c5..369f5e556df3 100644 --- a/drivers/pci/controller/dwc/pci-keystone.c +++ b/drivers/pci/controller/dwc/pci-keystone.c @@ -447,44 +447,10 @@ static struct pci_ops ks_child_pcie_ops = { .write = pci_generic_config_write, }; -/** - * ks_pcie_v3_65_add_bus() - keystone add_bus post initialization - * @bus: A pointer to the PCI bus structure. - * - * This sets BAR0 to enable inbound access for MSI_IRQ register - */ -static int ks_pcie_v3_65_add_bus(struct pci_bus *bus) -{ - struct dw_pcie_rp *pp = bus->sysdata; - struct dw_pcie *pci = to_dw_pcie_from_pp(pp); - struct keystone_pcie *ks_pcie = to_keystone_pcie(pci); - - if (!pci_is_root_bus(bus)) - return 0; - - /* Configure and set up BAR0 */ - ks_pcie_set_dbi_mode(ks_pcie); - - /* Enable BAR0 */ - dw_pcie_writel_dbi(pci, PCI_BASE_ADDRESS_0, 1); - dw_pcie_writel_dbi(pci, PCI_BASE_ADDRESS_0, SZ_4K - 1); - - ks_pcie_clear_dbi_mode(ks_pcie); - - /* - * For BAR0, just setting bus address for inbound writes (MSI) should - * be sufficient. Use physical address to avoid any conflicts. - */ - dw_pcie_writel_dbi(pci, PCI_BASE_ADDRESS_0, ks_pcie->app.start); - - return 0; -} - static struct pci_ops ks_pcie_ops = { .map_bus = dw_pcie_own_conf_map_bus, .read = pci_generic_config_read, .write = pci_generic_config_write, - .add_bus = ks_pcie_v3_65_add_bus, }; static struct pci_ops ks_pcie_am6_ops = { @@ -834,6 +800,23 @@ static int __init ks_pcie_host_init(struct dw_pcie_rp *pp) if (ret < 0) return ret; + if (!ks_pcie->is_am6) { + /* Configure and set up BAR0 */ + ks_pcie_set_dbi_mode(ks_pcie); + + /* Enable BAR0 */ + dw_pcie_writel_dbi(pci, PCI_BASE_ADDRESS_0, 1); + dw_pcie_writel_dbi(pci, PCI_BASE_ADDRESS_0, SZ_4K - 1); + + ks_pcie_clear_dbi_mode(ks_pcie); + + /* + * For BAR0, just setting bus address for inbound writes (MSI) should + * be sufficient. Use physical address to avoid any conflicts. + */ + dw_pcie_writel_dbi(pci, PCI_BASE_ADDRESS_0, ks_pcie->app.start); + } + #ifdef CONFIG_ARM /* * PCIe access errors that result into OCP errors are caught by ARM as -- 2.34.1