Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp6599058rwb; Wed, 18 Jan 2023 07:10:58 -0800 (PST) X-Google-Smtp-Source: AMrXdXuL/gXttVrR9xaiDpVdtyx/vWsGx2Q18TWJ6D5ZBA4ShNcHk98Z5C5K7eDyHInlI+08dMX1 X-Received: by 2002:a17:903:12cc:b0:194:c04c:deea with SMTP id io12-20020a17090312cc00b00194c04cdeeamr1225221plb.15.1674054657822; Wed, 18 Jan 2023 07:10:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674054657; cv=none; d=google.com; s=arc-20160816; b=PKFWOSquAHNuKm61ctfXaYqPxKlFkL63+7jYAjUPzmgaj+JsZUzR5tVa5Facsy8jWE LgwNnOrp/mKSVCdnt6+Vy48TkzThdIm3ahg1Z7UrDhydbNhOc6nWLCTN6mCo/42AO+to aqKSB03bPN1hHGLLGhRLA4NRxbqeMarlih8xTCsaUJxAwjM/WrUm3Wt8h0GztrS3g7yp uEBAEouteRTZzanaYoy27T1ajku9Z2dDwYM1dxs+/j0WT6vYOjZyguT9FzXv8HHOTs03 vxGYyoR53xTK3OcSkfRm62OY92drFMJqSvLCc8M/Ye+ce9mlj2XEtgMwH2rWFuyeJ5yc ItEw== 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=yeMuyvf0CNYri6p9yVKI+iipvOaqkrcmBQdptZ908h4=; b=eAJJEo4bIAQVTi+rNwnV5k/19yLlBr7oaghoi7+m+om4S2LZQFAnXlVFvpxBBYC5qJ H5QlGAQo/pr0r9PachkpFMEAcWhgOHJXFMT+j119NrOtoNAJJ8BPeyb3qAnjICWY2SUM lYhMYXvyMiBK5sifP628qDo5r1RVKuh3mJYkW7J1Ff5Ajp2hbVSnpGam/OIl7Nyou6dS Cd6Rrgb5x+0KFdbAFojTbJhT9CRx8mEeb+WEpUG9AZE4gf9qn/RFVwvInnMhmBeHzXWy eY5HNm89fRiwzxLv2CyV5/EwaL4quqKunRxFSyYzON1GqxQcVbycBPYJCd06s+cfO8nj wZaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=AYS1mSU4; 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 a2-20020a63e402000000b004a2f26de947si36732738pgi.224.2023.01.18.07.10.52; Wed, 18 Jan 2023 07:10:57 -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=AYS1mSU4; 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 S229880AbjARPGW (ORCPT + 45 others); Wed, 18 Jan 2023 10:06:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231305AbjARPGP (ORCPT ); Wed, 18 Jan 2023 10:06:15 -0500 Received: from lelv0143.ext.ti.com (lelv0143.ext.ti.com [198.47.23.248]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A91DA8A72; Wed, 18 Jan 2023 07:06:12 -0800 (PST) Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 30IF5m4n046516; Wed, 18 Jan 2023 09:05:48 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1674054348; bh=yeMuyvf0CNYri6p9yVKI+iipvOaqkrcmBQdptZ908h4=; h=From:To:CC:Subject:Date; b=AYS1mSU4HYBKioA7ETXVx5f1W6RrC1qL7cvnV3Bnhy9/Lny6YP3YFSY2kygkk2i5J ZYS4Wu5V5iRZqPTrNrRyC+Yvy+huzucz8InyGUcdbINsfDQUayRMSyjtsylp0GmXRP uvM555Y+PGW5fqdxIMFpgJ6figt21TDUgzmX0Rb8= Received: from DLEE109.ent.ti.com (dlee109.ent.ti.com [157.170.170.41]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 30IF5mPR090521 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 18 Jan 2023 09:05:48 -0600 Received: from DLEE102.ent.ti.com (157.170.170.32) by DLEE109.ent.ti.com (157.170.170.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.16; Wed, 18 Jan 2023 09:05:47 -0600 Received: from lelv0327.itg.ti.com (10.180.67.183) by DLEE102.ent.ti.com (157.170.170.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; Wed, 18 Jan 2023 09:05:47 -0600 Received: from localhost (ileaxei01-snat.itg.ti.com [10.180.69.5]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id 30IF5kUp114843; Wed, 18 Jan 2023 09:05:47 -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 v2] PCI: cadence: Fix next function value in case of ARI Date: Wed, 18 Jan 2023 20:35:46 +0530 Message-ID: <20230118150546.3477995-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 field in ARI_CAP_AND_CTR register for last function should be zero by default as per the PCIe spec but thats not the case, so this patch clears the next function field for last function used. Signed-off-by: Jasko-EXT Wojciech Signed-off-by: Achal Verma --- 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