Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp2326745rda; Tue, 24 Oct 2023 22:03:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG72Trg1O821yUdSN1Lk9t6qPcdg+q+KOF6Us+cLse2svRJEG63ruAMpC9en87RbboFG0Uc X-Received: by 2002:a05:6808:21aa:b0:3a9:9ce5:83a9 with SMTP id be42-20020a05680821aa00b003a99ce583a9mr19563963oib.50.1698210222585; Tue, 24 Oct 2023 22:03:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698210222; cv=none; d=google.com; s=arc-20160816; b=XyMi8q338so4MFtV4CQBqSMWh6M4d35ZiEoeujR4wy7w+ZLV3i8aJp4HoSKnbXSP5X noXppGBUKbFTzQts4homWD5jz4iuObu9bzEMr7VfeUJfFUMbpUSLqToekje/xhnJ66P0 epMUT0aMOkvuI7X4L1/6NNZWYpblz8LvQqLo2eAPRM9F8DdgIeP5Ak5rIxoI2zpSAJHR 4jviXKByGG3ZF+73MgXDu5XgIwZgXxvhJBjg/w7xIXDZzqd2LmG+qJ3MqMVe/wQWL6KQ n9KfNtP575sCApp0i6Vtslsd3OKw9Z9OR+LmABSJB9WZHOblV+TF+UH7XfDq49g1h/pX /IJw== 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 :content-language:references:cc:to:subject:from:user-agent :mime-version:date:message-id:dkim-signature; bh=3zOX6TUjyNNgjljAkOrTg04EXn1HnypXqTsDWnDgMkM=; fh=zPyA1QdaT4BNgJK9pK167XFTG9HJXBvGpi2u1Y3nqwQ=; b=iNg+f4RpJy6V6LGNhfjJUWPg/7ovIXhLZum/sWjHlUbap/uhq2+o0wDT90iMEt+xjr DieDZ9srO/AgfElvw5XNNTCum87GxgU49IQ/xvdbdkaErfS6gdovJjHGtblinTGroSXv iqXlP8Y3Y3NFTurg+H8A7h2X+AqMK1HCwjqFG+AVkTSleuSJGFFQsoAW71OYVFQ7Qve5 it/n1dvoIF+C+s4oLCk6UaTJGsV4z60IMG2224gjRqXw+ofr/9Gb0tbVxgLU7NCf5iXb AWMQMXP/5A37ooBrxPwBxYg2clftdwsY9PDnXETTVVxwQbduCaDzJEUrp6kE+XLNcoP1 4dmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=KiuO+Qi8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id d31-20020a25361f000000b00d9a5221821bsi1309032yba.498.2023.10.24.22.03.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 22:03:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=KiuO+Qi8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 6143A801C018; Tue, 24 Oct 2023 22:03:39 -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 S229587AbjJYFDS (ORCPT + 99 others); Wed, 25 Oct 2023 01:03:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229456AbjJYFDR (ORCPT ); Wed, 25 Oct 2023 01:03:17 -0400 Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A103E5; Tue, 24 Oct 2023 22:03:15 -0700 (PDT) Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 39P52tl9125931; Wed, 25 Oct 2023 00:02:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1698210175; bh=3zOX6TUjyNNgjljAkOrTg04EXn1HnypXqTsDWnDgMkM=; h=Date:From:Subject:To:CC:References:In-Reply-To; b=KiuO+Qi8x7F7wJgye1QmAuld7eE4GbP5+7VouFlMMzrYe/1EsnKgi7xGS9EhHZwch 7TcJL8kqBzGG8GKcPsetvmC8eGPDa29k5xKybyjnzP/PRR3j/jCehURfVV3hbitmU9 UUliMs4da9kAehXo99waO0OMJj4VjlF9x1HvMJIQ= Received: from DFLE100.ent.ti.com (dfle100.ent.ti.com [10.64.6.21]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 39P52tet103204 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 25 Oct 2023 00:02:55 -0500 Received: from DFLE104.ent.ti.com (10.64.6.25) by DFLE100.ent.ti.com (10.64.6.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Wed, 25 Oct 2023 00:02:55 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DFLE104.ent.ti.com (10.64.6.25) 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; Wed, 25 Oct 2023 00:02:55 -0500 Received: from [172.24.227.9] (ileaxei01-snat2.itg.ti.com [10.180.69.6]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id 39P52o6I019290; Wed, 25 Oct 2023 00:02:51 -0500 Message-ID: Date: Wed, 25 Oct 2023 10:32:50 +0530 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird From: Siddharth Vadapalli Subject: Re: [PATCH v3] PCI: keystone: Fix pci_ops for AM654x SoC To: Bjorn Helgaas , Serge Semin CC: Manivannan Sadhasivam , , , , , , , , , , References: <20231023212628.GA1627567@bhelgaas> Content-Language: en-US In-Reply-To: <20231023212628.GA1627567@bhelgaas> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit 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]); Tue, 24 Oct 2023 22:03:39 -0700 (PDT) Hello Bjorn, On 24/10/23 02:56, Bjorn Helgaas wrote: > On Mon, Oct 23, 2023 at 05:05:30PM +0530, Siddharth Vadapalli wrote: >> On 23/10/23 16:12, Serge Semin wrote: >> >> ... >> >>> Siddharth, if it won't be that much bother and you have an access to >>> the v3.65-based Keystone PCIe device, could you please have a look >>> whether it's possible to implement what Bjorn suggested? >> >> Unfortunately I don't have any SoC/Device with me that has the v3.65 PCIe >> controller, so I will not be able to test Bjorn's suggestion. > > Huh. 57e1d8206e48 ("MAINTAINERS: move Murali Karicheri to credits") > removed the maintainer for pci-keystone.c, so the driver hasn't had a > maintainer for over two years. > > Given the fact that there's no maintainer, I'm more than happy to take > a patch to move this code to somewhere in the host_init() callback, > even if you don't have the hardware to test it. Sure, I can work on a patch for it. The execution flow with the existing code is as follows: ks_pcie_probe() dw_pcie_host_init() pci_host_probe() ks_pcie_v3_65_add_bus() So I assume that as long as ks_pcie_v3_65_add_bus() is invoked after pci_host_probe(), it should be acceptable. With this understanding, I plan to move it immediately after the invocation to dw_pcie_host_init() within ks_pcie_probe() conditionally (based on the is_am6 flag). The new call trace with this change will look like: ks_pcie_probe() dw_pcie_host_init() pci_host_probe() ks_pcie_v3_65_add_bus() Since the .add_bus() method will be removed following this change, I suppose that the patch I post for it can be applied instead of this v3 patch which fixes pci_ops. The patch I plan to post as a replacement for the current patch which shall also remove the ks_pcie_v3_65_add_bus() and the .add_bus() method is: diff --git a/drivers/pci/controller/dwc/pci-keystone.c b/drivers/pci/controller/dwc/pci-keystone.c index 0def919f89fa..3933e857ecaa 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, }; /** @@ -1270,6 +1236,29 @@ static int ks_pcie_probe(struct platform_device *pdev) ret = dw_pcie_host_init(&pci->pp); if (ret < 0) goto err_get_sync; + + if (!ks_pcie->is_am6) { + /* + * For v3.65 DWC PCIe Controllers, setup BAR0 to enable + * inbound access for MSI_IRQ register. + */ + + /* 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); + } + break; case DW_PCIE_EP_TYPE: if (!IS_ENABLED(CONFIG_PCI_KEYSTONE_EP)) { Please review and let me know if this looks fine. If so, I will post the patch for it. -- Regards, Siddharth.