Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp646068rdb; Thu, 19 Oct 2023 15:09:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEcrdvz5vBvq7jS5lxxr6yU+QTHNJsmU7VwK7/drHfWW3yjDUa8GyWDYrxGZj+VzASwTCqN X-Received: by 2002:a05:6a00:cc8:b0:6bd:3157:2dfe with SMTP id b8-20020a056a000cc800b006bd31572dfemr42951pfv.7.1697753363748; Thu, 19 Oct 2023 15:09:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697753363; cv=none; d=google.com; s=arc-20160816; b=JauVpSdbgf7f4zwQJEDUAVG+ZIoAiAE4VdKl+I8NWHjKTuJSezKUYD4UJwX5Kn+hCu hAHrvuS4GpUcjEzaMmK6bigZu8e+MVBjkH8zqRhwwqVfOO3W12NrvjTTbA1BxSnOU0EC kZm3lRpxmFJFUScbm661S3oPXju9wQtXFioBkVFF9xP5YykeTc/e3QeXZahGcT+ZnSDZ 1oyysMhnjJ7Mzfde6p3SGzwAhDBoDYwifgwEu0b4ndRwHqjGoeayynlTGEde2aVpUc9S B9fSqFLsy0IbjjRgtAd9dKF4qb/yHs3ebjNK5Pj+c1eYd7Qx5GttK0zt/tr4O8PkruFJ R29w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=6yuxYR3wzPiABVlNCL1NYJAxknSr6mbmNJeen4Fh/nk=; fh=yLSmGFeH05Q1c3Ydj+Wt9otK2nNA3+p/RJG7YzFFoe4=; b=blSfFgFKqFmAGVqewmylwVfeIKkWeyYwU+jun1yglSAlKZgnUckZWFT4v6/gXUAHLs lS1Oc9X7jkdJ13oGULyBq2gxRK/cHLNX0LtgfZ5jl2Sl8Xonjo09kticyzCq3veiI6h8 L8QCMS+W1SI5m6i41Fq5wYc3WVUQtJpP5E6FLPDAkUnXZowbfmkBG+zc0xFmd0zGxQjH buhGvTSL+kDouxxfOHAf9Z0ybi0FSsqK5oD41kQVG1depUr2Zy2oqItydXZPAkj/F/TD Eeg4abEiSJi07S1tS3/Q78AROhMnUxMVOsxBDNK/PI8PG06qf/Jm6yBS+gOhAiqGkBYt lVxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UY7WFPw7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id n124-20020a632782000000b005acc951c57esi502858pgn.526.2023.10.19.15.09.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 15:09:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UY7WFPw7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 7DF7F81E5551; Thu, 19 Oct 2023 15:09:17 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346641AbjJSWI6 (ORCPT + 99 others); Thu, 19 Oct 2023 18:08:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230120AbjJSWIv (ORCPT ); Thu, 19 Oct 2023 18:08:51 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3DF3112; Thu, 19 Oct 2023 15:08:49 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6C607C433C8; Thu, 19 Oct 2023 22:08:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697753329; bh=5nWEspGQsqIlXLWlQgxxPQ2KwD63lq+0D9hGkCIuI9s=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=UY7WFPw7Knkz/fhmpDW3uN5R3SE/bYFYam4auTj32WhIEkai6nT1cgsj52xtnd5ed 6v9RQTW3IigxxbLXTzcYBrYAJOTM1aV/OEWr9VAG6mZ+AUYVSaT+bZ/UhLwPP3fvD6 LnQF+o+bF+cBhVlSbkx5KfdbFB3WZMQRNcPh03cKIVS8EdanJ2Agcoxz42tlETKg5N 3GUDq9lQHGxMvlM4Brao5bR25dEzJG8IncTqbCF2QiOCta7/SGjeV8uHOAsqW8fjVq 6YLn3+7d0FILOrYNfDVc6M/HtW1ersC8z/lsXzThZh8msYv0rbJYX3TeLleFzf9JnP KzcoL/W1oy4/A== Date: Thu, 19 Oct 2023 17:08:47 -0500 From: Bjorn Helgaas To: Serge Semin Cc: Siddharth Vadapalli , bhelgaas@google.com, lpieralisi@kernel.org, robh@kernel.org, kw@linux.com, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, r-gunasekaran@ti.com, srk@ti.com Subject: Re: [PATCH v3] PCI: keystone: Fix pci_ops for AM654x SoC Message-ID: <20231019220847.GA1413474@bhelgaas> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 pete.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 (pete.vger.email [0.0.0.0]); Thu, 19 Oct 2023 15:09:18 -0700 (PDT) On Thu, Oct 19, 2023 at 01:05:24PM +0300, Serge Semin wrote: > On Thu, Oct 19, 2023 at 01:43:30PM +0530, Siddharth Vadapalli wrote: > > In the process of converting .scan_bus() callbacks to .add_bus(), the > > ks_pcie_v3_65_scan_bus() function was changed to ks_pcie_v3_65_add_bus(). > > The .scan_bus() method belonged to ks_pcie_host_ops which was specific > > to controller version 3.65a, while the .add_bus() method had been added > > to ks_pcie_ops which is shared between the controller versions 3.65a and > > 4.90a. Neither the older ks_pcie_v3_65_scan_bus() method, nor the newer > > ks_pcie_v3_65_add_bus() method are applicable to the controller version > > 4.90a which is present in AM654x SoCs. > > > > Thus, fix this by creating ks_pcie_am6_ops for the AM654x SoC which uses DW > > PCIe IP-core version 4.90a controller and omitting the .add_bus() method > > which is not applicable to the 4.90a controller. Update ks_pcie_host_init() > > accordingly in order to set the pci_ops to ks_pcie_am6_ops if the platform > > is AM654x SoC and to ks_pcie_ops otherwise, by making use of the "is_am6" > > flag. > > > > Fixes: 6ab15b5e7057 ("PCI: dwc: keystone: Convert .scan_bus() callback to use add_bus") > > Signed-off-by: Siddharth Vadapalli > > LGTM. Thanks! > Reviewed-by: Serge Semin > > One more note is further just to draw attention to possible driver > simplifications. > > > --- > > Hello, > > > > This patch is based on linux-next tagged next-20231018. > > > > The v2 of this patch is at: > > https://lore.kernel.org/r/20231018075038.2740534-1-s-vadapalli@ti.com/ > > > > Changes since v2: > > - Implemented Serge's suggestion of adding a new pci_ops structure for > > AM654x SoC using DWC PCIe IP-core version 4.90a controller. > > - Created struct pci_ops ks_pcie_am6_ops for AM654x SoC without the > > .add_bus method while retaining other ops from ks_pcie_ops. > > - Updated ks_pcie_host_init() to set pci_ops to ks_pcie_am6_ops if the > > platform is AM654x and to ks_pcie_ops otherwise by making use of the > > already existing "is_am6" flag. > > - Combined the section: > > if (!ks_pcie->is_am6) > > pp->bridge->child_ops = &ks_child_pcie_ops; > > into the newly added ELSE condition. > > > > The v1 of this patch is at: > > https://lore.kernel.org/r/20231011123451.34827-1-s-vadapalli@ti.com/ > > > > While there are a lot of changes since v1 and this patch could have been > > posted as a v1 patch itself, I decided to post it as the v2 of the patch > > mentioned above since it aims to address the issue described by the v1 > > patch and is similar in that sense. However, the solution to the issue > > described in the v1 patch appears to be completely different from what > > was implemented in the v1 patch. Thus, the commit message and subject of > > this patch have been modified accordingly. > > > > Changes since v1: > > - Updated patch subject and commit message. > > - Determined that issue is not with the absence of Link as mentioned in > > v1 patch. Even with Link up and endpoint device connected, if > > ks_pcie_v3_65_add_bus() is invoked and executed, all reads to the > > MSI-X offsets return 0xffffffff when pcieport driver attempts to setup > > AER and PME services. The all Fs return value indicates that the MSI-X > > configuration is failing even if Endpoint device is connected. This is > > because the ks_pcie_v3_65_add_bus() function is not applicable to the > > AM654x SoC which uses DW PCIe IP-core version 4.90a. > > > > Regards, > > Siddharth. > > > > drivers/pci/controller/dwc/pci-keystone.c | 13 +++++++++++-- > > 1 file changed, 11 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/pci/controller/dwc/pci-keystone.c b/drivers/pci/controller/dwc/pci-keystone.c > > index 49aea6ce3e87..66341a0b6c6b 100644 > > --- a/drivers/pci/controller/dwc/pci-keystone.c > > +++ b/drivers/pci/controller/dwc/pci-keystone.c > > @@ -487,6 +487,12 @@ static struct pci_ops ks_pcie_ops = { > > .add_bus = ks_pcie_v3_65_add_bus, > > }; > > > > +static struct pci_ops ks_pcie_am6_ops = { > > + .map_bus = dw_pcie_own_conf_map_bus, > > + .read = pci_generic_config_read, > > + .write = pci_generic_config_write, > > +}; > > + > > /** > > * ks_pcie_link_up() - Check if link up > > * @pci: A pointer to the dw_pcie structure which holds the DesignWare PCIe host > > @@ -804,9 +810,12 @@ static int __init ks_pcie_host_init(struct dw_pcie_rp *pp) > > struct keystone_pcie *ks_pcie = to_keystone_pcie(pci); > > int ret; > > > > - pp->bridge->ops = &ks_pcie_ops; > > - if (!ks_pcie->is_am6) > > + if (ks_pcie->is_am6) { > > + pp->bridge->ops = &ks_pcie_am6_ops; > > + } else { > > > + pp->bridge->ops = &ks_pcie_ops; > > pp->bridge->child_ops = &ks_child_pcie_ops; > > Bjorn, could you please clarify the next suggestion? I'm not that > fluent in the PCIe core details, but based on the > pci_host_bridge.child_ops and pci_host_bridge.ops names, the first ops > will be utilized for the child (non-root) PCIe buses, meanwhile the > later ones - for the root bus only (see pci_alloc_child_bus()). Right? I think so. 07e292950b93 ("PCI: Allow root and child buses to have different pci_ops") says: PCI host bridges often have different ways to access the root and child bus config spaces. The host bridge drivers have invented their own abstractions to handle this. Let's support having different root and child bus pci_ops so these per driver abstractions can be removed. https://git.kernel.org/linus/07e292950b93 > If so then either the pci_is_root_bus() check can be dropped from the > ks_pcie_v3_65_add_bus() method since the ops it belong to will be > utilized for the root bus anyway, or the entire ks_child_pcie_ops > instance can be dropped since the ks_pcie_v3_65_add_bus() method will > be no-op for the child buses anyway meanwhile ks_child_pcie_ops > matches to ks_pcie_ops in the rest of the ops. After doing that I > would have also changed the ks_pcie_v3_65_add_bus name to > ks_pcie_v3_65_add_root_bus() in anyway. Am I right? Probably so. But I don't think this code should be in an .add_bus() method in the first place. Ideally I think the content of ks_pcie_v3_65_add_bus() would move to the ks_pcie_host_init() path so we wouldn't need the .add_bus() hook at all. I think it was added as ks_dw_pcie_v3_65_scan_bus() by 0c4ffcfe1fbc ("PCI: keystone: Add TI Keystone PCIe driver"), which doesn't explain why doing this after scanning the secondary bus is needed. The .scan_bus() hook was added by b14a3d1784a9 ("PCI: designware: Add support for v3.65 hardware"), which says: 3. MSI interrupt generation requires EP to write to the RC's application register. So enhance the driver to allow setup of inbound access to MSI IRQ register as a post scan bus API callback. That's not a convincing argument for why the BAR setup has to be done *after* enumerating the endpoints, but presumably there was some reason. Bjorn