Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp1570094rdb; Sat, 2 Dec 2023 00:51:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IG4Pg8e+9721nqhWu4oHyuf6D+lYoZ0+ecoWCECRklUvSu+BH1cfj4rN+Qma10j4Oss6Gxu X-Received: by 2002:a05:6808:3010:b0:3b8:b063:9b6b with SMTP id ay16-20020a056808301000b003b8b0639b6bmr1204110oib.93.1701507066022; Sat, 02 Dec 2023 00:51:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701507065; cv=none; d=google.com; s=arc-20160816; b=krXLZ+kN9t2mIZ2uN/yIUdun4VN9cCHEULFV7cM+TvsZPxgkVpuCA0YkGNcy90hbUM MduzKiA7egzcTITBhqwZTl2XPX9nJknLfQ2Mi1MHJYz8AFAdizE8qwwBaj1YaCtoLfJE QUHKQGSNQ7K66DscKatKq73DvLY3nBZ6QS+atx9xPZBZ9UuMGBbGaqzje9YsEcuIogOI rFvPhFIz5dFpeYQf1tqPD2S3ndsyg09tTFet9Lukswjjrq1YKK7Nd+pVgwwejadkI26c pxnfxi2cTrFVkSekHhu4+w/rDIRKIyfLzF/P0VgSrRGcD7vVK1WbdcJdTUmYwxAkRObz szDg== 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=5eLMeR7O3XmgWYr3v/Y9HZ53t+c9lMwwKXavX+OjuwA=; fh=QzqD1z0doHU7eK/7BUTi9JRL1aq0afUmc1MPK7DN7AU=; b=cc+cEbq+gBXlLQV4S41f/IbGG2pDLNE1Rq1QGeY40SSUbxCdsC1rnIj8gGJ8gYC4Jr EtfapHM1yHHTUD2khCpPKlJOYyUQ4Y7b+wqpcOLQvi7Wx8jJxLzc/pWIVRWz5BVOjTw2 P/5q97XxlVv/P4kxXDf6YRIkFXWUKxRgD9GfbmUA877Bg80IvRzf59n0xJShIaM8G+g/ XYuMP0E6b4woUKvlTTCGxZsTXR4fSjSsNHsJpyeZA80uMO3KhVG4wLfzxqfy7FSkqgTt 8Xk3VA1Nb6cWg+CELqvJms7YK9Qc3OqQSHUn/cAsafRvgXUaAbEjs5tYy/a1JS5Wk+EE /5RA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=uPnW9bc0; 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 r5-20020a632045000000b005be3c0443e7si4736295pgm.643.2023.12.02.00.51.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Dec 2023 00:51:05 -0800 (PST) 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=uPnW9bc0; 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 4FF50808BDB2; Sat, 2 Dec 2023 00:51:02 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231527AbjLBIue (ORCPT + 99 others); Sat, 2 Dec 2023 03:50:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231223AbjLBIuc (ORCPT ); Sat, 2 Dec 2023 03:50:32 -0500 Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01F3AEB; Sat, 2 Dec 2023 00:50:37 -0800 (PST) Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 3B28oJvO048633; Sat, 2 Dec 2023 02:50:19 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1701507019; bh=5eLMeR7O3XmgWYr3v/Y9HZ53t+c9lMwwKXavX+OjuwA=; h=From:To:CC:Subject:Date; b=uPnW9bc0vJAgRIKvDOPa9kPaxyHNisBdNDhx+Xt7hyEAl4H71vXLypp+pm3aol2TV kzGVOWxwUPF+Bx84qEFNSWr8R+FceRZkJNOc+1dasAv/tbsXuWRrIKk2TImFKRMcJq oJsNwMf45Ia4opPErFX6h131kWvLFVo9RfMKWtnE= Received: from DLEE110.ent.ti.com (dlee110.ent.ti.com [157.170.170.21]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 3B28oJE9002281 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Sat, 2 Dec 2023 02:50:19 -0600 Received: from DLEE114.ent.ti.com (157.170.170.25) by DLEE110.ent.ti.com (157.170.170.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Sat, 2 Dec 2023 02:50:19 -0600 Received: from fllv0040.itg.ti.com (10.64.41.20) by DLEE114.ent.ti.com (157.170.170.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; Sat, 2 Dec 2023 02:50:19 -0600 Received: from uda0492258.dhcp.ti.com (ileaxei01-snat2.itg.ti.com [10.180.69.6]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id 3B28oGEW067220; Sat, 2 Dec 2023 02:50:16 -0600 From: Siddharth Vadapalli To: , , , CC: , , , , , , Subject: [PATCH v4] PCI: Cadence: Clear the ARI Capability Next Function Number of the last function Date: Sat, 2 Dec 2023 14:20:15 +0530 Message-ID: <20231202085015.3048516-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,T_SCC_BODY_TEXT_LINE 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]); Sat, 02 Dec 2023 00:51:02 -0800 (PST) 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 Reviewed-by: Vignesh Raghavendra Signed-off-by: Siddharth Vadapalli --- Hello, This patch is based on linux-next tagged next-20231201. v3: https://patchwork.kernel.org/project/linux-pci/patch/20230316071156.200888-1-a-verma1@ti.com/ Changes since v3: - Rebased on next-20231201. - Collected Reviewed-by tag from Vignesh Raghavendra . Regards, Siddharth. 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 3142feb8ac19..2dd4d7027659 100644 --- a/drivers/pci/controller/cadence/pcie-cadence-ep.c +++ b/drivers/pci/controller/cadence/pcie-cadence-ep.c @@ -566,7 +566,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 @@ -574,6 +575,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 373cb50fcd15..9c16745582eb 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.34.1