From patchwork Thu Jan 19 12:42:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Achal Verma X-Patchwork-Id: 45741 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp305830wrn; Thu, 19 Jan 2023 04:47:18 -0800 (PST) X-Google-Smtp-Source: AMrXdXvGFIQQJw+hAsoIJCjiVsWKwjgV6NnAGqVKENK7rTbT15LiUwAe0XisjiKXCZNBI97T6Oa2 X-Received: by 2002:a17:90b:887:b0:229:5041:c590 with SMTP id bj7-20020a17090b088700b002295041c590mr10798139pjb.18.1674132438345; Thu, 19 Jan 2023 04:47:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674132438; cv=none; d=google.com; s=arc-20160816; b=IeFutYINQgxWwE3sMpqJnwttFQ8AMdcbKxuEJiQl9qPsR5/60LjM+1uPUDuu3cq3Mf NoRnigie8prC5UZPf7fmWFMIVLmvvmnJtlRL4QhR07SADZ4xZTG4obbVVsTRWU5NO0x7 L4Z7bSCgVjJWof5B0kbhOVmqfZFf77tGZfQqY7GYR19vmLHh/6qdApIWPkdyjG8ahwHP /x/HGJE3jcjHwh7d7bRz4h9YJWuEruMYyGUsrY67kGEXN5sAaLdRcGMYkZYRwwuqLG3h N1Llasf8lgzWdnypiHcQnsXRKvCXlLrO+xwxPXkUSOqLA1wuqYKnTU97M1xDuGSRdSAI n++A== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h8-20020a17090acf0800b0020354bcfe09si5160264pju.129.2023.01.19.04.47.05; Thu, 19 Jan 2023 04:47:18 -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 + 99 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755455095788798980?= X-GMAIL-MSGID: =?utf-8?q?1755455095788798980?= 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) */