Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp957260rwb; Thu, 19 Jan 2023 05:03:04 -0800 (PST) X-Google-Smtp-Source: AMrXdXucRhU5a2mrcMBiIwlslv+hsOI+DIf5ntsOOD5ZzNVVCLP+e5Zx6zVWiFao5X45FB1nj/Ef X-Received: by 2002:a17:907:a80b:b0:86f:220e:94af with SMTP id vo11-20020a170907a80b00b0086f220e94afmr21482180ejc.56.1674133384331; Thu, 19 Jan 2023 05:03:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674133384; cv=none; d=google.com; s=arc-20160816; b=PSogq/OMqAn70PWOr9ZDUlR+V7juFBnVN9+EItG7i+Ybd4OPnjkzPloezjKMmtqc6O DfWvafbOiYAwglAdsh2pMMk/QaUh61hoWgY5bYzq2IDDlwzCVwxepe2TcJfw+KntKjIH T+13WM2W6OaZHQnbBNFmCKtQkkE0logEzpNOhxWKok6CsSSPRroe9ReYgo+rM9Uv2OWe az/4oP0GvH48HxuRyPWNBcihefgD+WUPh5uMI8tOZy/tv+bKyxF6iwv6JB8kAiNDupOt g6aoJoub141Fi1TMwRkT5c8Z0uETVvXGTsmAu4XTA/OqqNJsV8Pj71jbgCeh1QxyZVCP tmXw== 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=rrGNNPXq+BYqGfjYbQ93imPXCXjcdDhNhhQzNksCYlg=; b=KLYLDJwBotHvqhgYYMzGyQrviEtEkkTJKoahXm++1mmEaYX1ZcnHmfumayhFiv4p8h 2lo77mHcmtzGU0tl9TQ90Skk5Pb6p0AcKraTyQGAR7/Hgs4QYUGi2e3YRIxr45fRGah+ th+Le//HM/dcm54Jbx9256lG8QZ5q8dHvpjyC2Eq09N5N5Zl9uaoEnTs67OkxLxaxEdA nR+tb2fX2xJfT4YMWBzAbXjqK2y/BBfgduZCRrAUBQmgoEagQAH9g9TYauwRMdur3CiZ 23Dktty9tyLB8gV1KpyeKXFwYG/LUAt+1SYFatP//gh2m7/NE00Oq7MY1fWjMv5Mf7yt MTtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=geo8ALUe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id wz8-20020a170906fe4800b007ae9f42f86esi17424844ejb.383.2023.01.19.05.02.53; Thu, 19 Jan 2023 05:03:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=geo8ALUe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229916AbjASMpG (ORCPT + 44 others); Thu, 19 Jan 2023 07:45:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230044AbjASMoO (ORCPT ); Thu, 19 Jan 2023 07:44:14 -0500 Received: from lelv0142.ext.ti.com (lelv0142.ext.ti.com [198.47.23.249]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B74C435B6; Thu, 19 Jan 2023 04:42:53 -0800 (PST) Received: from fllv0034.itg.ti.com ([10.64.40.246]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 30JCgcLL113125; Thu, 19 Jan 2023 06:42:38 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1674132159; bh=rrGNNPXq+BYqGfjYbQ93imPXCXjcdDhNhhQzNksCYlg=; h=From:To:CC:Subject:Date; b=geo8ALUeqZEBHyUq8YFoDnV6eGCRCbqxrmXAguaHP/dLQG32TXe4gWPsCDcfdsdpc Oi0UogIXPEontflefNeMK/1PW0DPDvEoHJPfsY/Kub9T2nKjP6vM+hrAAgx8f15jNc gsCNuj40yM37yCo1vC+M/ueGX7gLpJMpsIZ6KP04= Received: from DFLE109.ent.ti.com (dfle109.ent.ti.com [10.64.6.30]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 30JCgcH2075848 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 19 Jan 2023 06:42:38 -0600 Received: from DFLE111.ent.ti.com (10.64.6.32) by DFLE109.ent.ti.com (10.64.6.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.16; Thu, 19 Jan 2023 06:42:38 -0600 Received: from fllv0039.itg.ti.com (10.64.41.19) by DFLE111.ent.ti.com (10.64.6.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.16 via Frontend Transport; Thu, 19 Jan 2023 06:42:38 -0600 Received: from localhost (ileaxei01-snat2.itg.ti.com [10.180.69.6]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 30JCgbID004691; Thu, 19 Jan 2023 06:42:38 -0600 From: Achal Verma To: Tom Joseph , Lorenzo Pieralisi , Rob Herring , Krzysztof Wilczy_ski , Bjorn Helgaas , Vignesh Raghavendra CC: , , , , Achal Verma , Milind Parab Subject: [PATCH v3] PCI: cadence: Clear the ARI Capability Next Function Number of the last function Date: Thu, 19 Jan 2023 18:12:37 +0530 Message-ID: <20230119124237.3499590-1-a-verma1@ti.com> X-Mailer: git-send-email 2.25.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=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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 From: Jasko-EXT Wojciech Next Function Number field in ARI Capability Register for last function must be zero by default as per the PCIe specification, indicating there is no next higher number function but that's not happening in our case, so this patch clears the Next Function Number field for last function used. Signed-off-by: Jasko-EXT Wojciech Signed-off-by: Achal Verma --- Changes from v2: * Rework the commit message. drivers/pci/controller/cadence/pcie-cadence-ep.c | 14 +++++++++++++- drivers/pci/controller/cadence/pcie-cadence.h | 6 ++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/pci/controller/cadence/pcie-cadence-ep.c b/drivers/pci/controller/cadence/pcie-cadence-ep.c index b8b655d4047e..8742b2f594fd 100644 --- a/drivers/pci/controller/cadence/pcie-cadence-ep.c +++ b/drivers/pci/controller/cadence/pcie-cadence-ep.c @@ -565,7 +565,8 @@ static int cdns_pcie_ep_start(struct pci_epc *epc) struct cdns_pcie *pcie = &ep->pcie; struct device *dev = pcie->dev; int max_epfs = sizeof(epc->function_num_map) * 8; - int ret, value, epf; + int ret, epf, last_fn; + u32 reg, value; /* * BIT(0) is hardwired to 1, hence function 0 is always enabled @@ -573,6 +574,17 @@ static int cdns_pcie_ep_start(struct pci_epc *epc) */ cdns_pcie_writel(pcie, CDNS_PCIE_LM_EP_FUNC_CFG, epc->function_num_map); + /* + * Next function field in ARI_CAP_AND_CTR register for last function + * should be 0. + * Clearing Next Function Number field for the last function used. + */ + last_fn = find_last_bit(&epc->function_num_map, BITS_PER_LONG); + reg = CDNS_PCIE_CORE_PF_I_ARI_CAP_AND_CTRL(last_fn); + value = cdns_pcie_readl(pcie, reg); + value &= ~CDNS_PCIE_ARI_CAP_NFN_MASK; + cdns_pcie_writel(pcie, reg, value); + if (ep->quirk_disable_flr) { for (epf = 0; epf < max_epfs; epf++) { if (!(epc->function_num_map & BIT(epf))) diff --git a/drivers/pci/controller/cadence/pcie-cadence.h b/drivers/pci/controller/cadence/pcie-cadence.h index 190786e47df9..68c4c7878111 100644 --- a/drivers/pci/controller/cadence/pcie-cadence.h +++ b/drivers/pci/controller/cadence/pcie-cadence.h @@ -130,6 +130,12 @@ #define CDNS_PCIE_EP_FUNC_DEV_CAP_OFFSET 0xc0 #define CDNS_PCIE_EP_FUNC_SRIOV_CAP_OFFSET 0x200 +/* + * Endpoint PF Registers + */ +#define CDNS_PCIE_CORE_PF_I_ARI_CAP_AND_CTRL(fn) (0x144 + (fn) * 0x1000) +#define CDNS_PCIE_ARI_CAP_NFN_MASK GENMASK(15, 8) + /* * Root Port Registers (PCI configuration space for the root port function) */ -- 2.25.1