From patchwork Thu Mar 16 06:54:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Achal Verma X-Patchwork-Id: 70596 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp327652wrt; Thu, 16 Mar 2023 00:09:56 -0700 (PDT) X-Google-Smtp-Source: AK7set/xpnG4bBByl2DSi5vaFHjYqbRjPzWVeGTpIauJi2y+Ouv2vzqUPJgZYp/g14K1DYnPjs0L X-Received: by 2002:a17:902:ecc9:b0:19e:5cc3:828f with SMTP id a9-20020a170902ecc900b0019e5cc3828fmr2687452plh.27.1678950595946; Thu, 16 Mar 2023 00:09:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678950595; cv=none; d=google.com; s=arc-20160816; b=Z2b8378qzVr11tPzwXx0kuzpPOBr5Vfnbfk4mP5XCpsdtwTHsja8Tb8SOLKabemwol kU3xtnnATar4wA2dB2nP5lIoKM4J0NNacapLhDFYYxnqn0ZURccc4+vsYczkHyQXAZRa /9F/jy3zGHH2y9B7x5lndLVpbQd0CsmHyhKl5AAsZgqptC1bo0oyZhxi91l6ErzcHTnB E1Fl8MTYGI1BCJFAuCceauGLvfjLybdHPIkAgYSVOOkkTc8Tv5CVAvTwAcGJn8uGMPrv 8N1/yCZIot5QDBsulGFm93O1ZTwmHHnmvnwQ5yRH4SGAlq/lQFDbbb54yeTFcoEDC1UC dP/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=2Gpcf7N6et2DzkZGXjiuERa4sq1e3jWKbNIVNuiOBLo=; b=0SAf2sk3ru/TiN2DnPnO6OZx7VLIUGHiEkd/O7Ji6BBGgXbfzoRqD5NoEBqOhuZBna DGS6HBiBNLsO+k51zQqUJL5T+jC2FYPdnra7OUCwL9VJuO2/P54MQpS187L5TzI4EHLR jjzhpHyfIB5BRPM4HxvIxufajjBfao+Rc0nCNXsGME7OnQAYIgSdtRmyp64eNGLgZzKT 3/ja3psCrrhvBtR5WDaj47tqv30seUWs8RTxfD1K6FhX4k2b97kj22M8aSn06aX+/PHW aZQGkVljAkrEd5MB6+YZjs9Ax8tERiflpo4BuxWc73jwjINWEHvcI7ff/IuoHgVVZx/l bJKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=F3Ju1ePJ; 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 jw3-20020a170903278300b0019abafb4d46si6930463plb.299.2023.03.16.00.09.40; Thu, 16 Mar 2023 00:09:55 -0700 (PDT) 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=F3Ju1ePJ; 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 S229875AbjCPGzT (ORCPT + 99 others); Thu, 16 Mar 2023 02:55:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229648AbjCPGzR (ORCPT ); Thu, 16 Mar 2023 02:55:17 -0400 Received: from fllv0016.ext.ti.com (fllv0016.ext.ti.com [198.47.19.142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4F4D7F014; Wed, 15 Mar 2023 23:55:15 -0700 (PDT) Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 32G6sv5Z020892; Thu, 16 Mar 2023 01:54:57 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1678949697; bh=2Gpcf7N6et2DzkZGXjiuERa4sq1e3jWKbNIVNuiOBLo=; h=From:To:CC:Subject:Date; b=F3Ju1ePJ6BH7dwUdKwFcKjoR51n9vKTLfNxH0E2oq+wlh4FOJmdl31rX6v2NqCvjt qusdqyh3ffx3TaJqW41l0fds+QBDr/FIOsGnyvqN+pY3sgGc1SnEnUXpdKZBnqkqBM o1SEeBOfNyHMSLKjUgTAhtCXRngtwZMoS8MqQR08= Received: from DLEE109.ent.ti.com (dlee109.ent.ti.com [157.170.170.41]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 32G6sveS026521 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 16 Mar 2023 01:54:57 -0500 Received: from DLEE112.ent.ti.com (157.170.170.23) 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; Thu, 16 Mar 2023 01:54:56 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DLEE112.ent.ti.com (157.170.170.23) 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, 16 Mar 2023 01:54:56 -0500 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 32G6st42056317; Thu, 16 Mar 2023 01:54:56 -0500 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, 16 Mar 2023 12:24:55 +0530 Message-ID: <20230316065455.191785-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?1760507299965170287?= X-GMAIL-MSGID: =?utf-8?q?1760507299965170287?= 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 v1: * Fix commments in the code. 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) */