From patchwork Tue Apr 11 16:59:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 13207911 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C3918C77B76 for ; Tue, 11 Apr 2023 17:00:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Ioj2QdBCO+s+EmhiHrlyBE7Gn5RsUHD/FQFfFu8sF+o=; b=w+wdaEPBs5kiY9 oNTOHiCDlHJ0/lYkk25rIz6B43P8gHyrDtwVxn17are0yCKRcGOSGixiuRV9gkDeJquym5723jvyH hWG/w5THCsIBb4umv6G1OlZi+/exa9p9aWLR0gY+zQR5V0wUoAlU8AKW7EGjKI80HDluwTY1yWXRG Kr4Ej7sBHjQpwlwNwYOORuZzrErHEfHFhnr8ykO5SWVL4CVVTCXvHbPR+RiDj58XldNg0+LaiPEDV q1QQ/41cAjOTBgFlbXTUoDcmI+1TCiMWiHBEadObmV+dgiK2qQmHZ1R8Cuo9VxBdVqZaSpTlCbJCi k7DV4bhZ30hnPwFVT2Gg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pmHLI-000dxp-27; Tue, 11 Apr 2023 16:59:40 +0000 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pmHLF-000duZ-1r; Tue, 11 Apr 2023 16:59:38 +0000 Received: by mail-pl1-x62c.google.com with SMTP id n14so33583822plc.8; Tue, 11 Apr 2023 09:59:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681232373; x=1683824373; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=LU4fDGYnSqojPlNTpXEuI7OFxxokivytfp/gN0CUpGU=; b=eCFQ+5CbxIUbqO9fjDVXP24ENvhLMQJsJzLcNLVyJ5eKPZKNjDendq5Q4g8mAEDpaK vk4eksJe7J09lpCgdiC9Mtt/AeYUTI+NCnc+3QBGQbNG1gUcVYTRX6iF4uWBTkaSR57e MAtfOJfNNqLnsaNMaOYvDcmBPIt6i4A+fANzue3LkMtwFZ3lrmYiOsMQ8sr/vzgtIO/v S2U0BiySmimUl64DJb5IQ24Iw+hBqAbuFb+PZ4G4AzOln0fb5rJrPLHq3RO/HmwyWrtW jEW1Rg65zx53lZjQvvD7SP1MwIIEjKxepNZSBhc6djgR8nbgnSx6XbhTnzQeNDf3vQiO FM5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681232373; x=1683824373; h=references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=LU4fDGYnSqojPlNTpXEuI7OFxxokivytfp/gN0CUpGU=; b=KlTYMnyny4J+4I4IllLU9k/95cmZC0Y8DiGLFRl+3w7QXqfH5LeKh0zdigCaQa8Aa0 AJlAwkmGYrfY8WO+olaGPZBMU+kUhrqvqBlNPzLioOQY2MgqXOa/PTx9G+k0ru60FMWp AtSNSNLImmrbFmt0UJwG8WDMc+VStjKVUf8Y0w+8EZbB+Ps6XUpJ/FU5TpXHEbhifyyO ZTHdDFtCMx3vU6J1+Dho7OuhDAbxDCT5kafTxtFujsIKwr7s9+sahawaHM3LQoTSvKkV pX+nKXU5yxzntdA1B7NTbo2GeuKretMf2DBRREnuz4nXeDniI3uak7jukOAsmanxbZdz wdNg== X-Gm-Message-State: AAQBX9c2snEk5KZIlLFjKeoXGiZslrq4H3yrdaHXcvPEH0jCG2UZdN2A mEtwo8XeioqmecNgyA4BtPE= X-Google-Smtp-Source: AKy350akxZlDkkyabSOqZId6p8YpUJ6BgqqQxQ8HpAYPLDESNBj6AnA2efYes/J53xPvbNJjeMuC7A== X-Received: by 2002:a05:6a20:4a22:b0:d9:8b07:eb08 with SMTP id fr34-20020a056a204a2200b000d98b07eb08mr2603608pzb.21.1681232373452; Tue, 11 Apr 2023 09:59:33 -0700 (PDT) Received: from stbsrv-and-01.and.broadcom.net ([192.19.144.250]) by smtp.gmail.com with ESMTPSA id m6-20020aa79006000000b0063989aab89fsm3484519pfo.23.2023.04.11.09.59.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Apr 2023 09:59:33 -0700 (PDT) From: Jim Quinlan To: linux-pci@vger.kernel.org, Nicolas Saenz Julienne , Bjorn Helgaas , Lorenzo Pieralisi , Cyril Brulebois , Phil Elwell , bcm-kernel-feedback-list@broadcom.com, jim2101024@gmail.com, james.quinlan@broadcom.com Cc: Florian Fainelli , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Rob Herring , linux-rpi-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), linux-arm-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2 3/3] PCI: brcmstb: Set PCIe transaction completion timeout Date: Tue, 11 Apr 2023 12:59:18 -0400 Message-Id: <20230411165919.23955-4-jim2101024@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230411165919.23955-1-jim2101024@gmail.com> References: <20230411165919.23955-1-jim2101024@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230411_095937_614688_509B723C X-CRM114-Status: GOOD ( 13.60 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Since the STB PCIe HW will cause a CPU abort on a PCIe transaction completion timeout abort, we might as well extend the default timeout limit. Further, different devices and systems may requires a larger or smaller amount commensurate with their L1SS exit time, so the property "brcm,completion-abort-us" may be used to set a custom timeout value. Signed-off-by: Jim Quinlan --- drivers/pci/controller/pcie-brcmstb.c | 30 +++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c index 56b96aa02221..9610066f8c80 100644 --- a/drivers/pci/controller/pcie-brcmstb.c +++ b/drivers/pci/controller/pcie-brcmstb.c @@ -1080,6 +1080,35 @@ static void brcm_config_clkreq(struct brcm_pcie *pcie) writel(clkreq_set, pcie->base + PCIE_MISC_HARD_PCIE_HARD_DEBUG); } +static void brcm_config_completion_timeout(struct brcm_pcie *pcie) +{ + /* TIMEOUT register is two registers before RGR1_SW_INIT_1 */ + const char *fmt = "brcm,completion-timeout-us clamped to region [%u..%u]\n"; + const unsigned int REG_OFFSET = PCIE_RGR1_SW_INIT_1(pcie) - 8; + const u32 timeout_us_min = 16; + const u32 timeout_us_max = 19884107; + u32 timeout_us = 1000000; /* Our default, 1 second */ + int rval, ret; + + ret = of_property_read_u32(pcie->np, "brcm,completion-timeout-us", + &timeout_us); + if (ret && ret != -EINVAL) + dev_err(pcie->dev, "malformed/invalid 'brcm,completion-timeout-us'\n"); + + /* If needed, clamp the requested timeout value and issue a warning */ + if (timeout_us < timeout_us_min) { + timeout_us = timeout_us_min; + dev_warn(pcie->dev, fmt, timeout_us_min, timeout_us_max); + } else if (timeout_us > timeout_us_max) { + timeout_us = timeout_us_max; + dev_warn(pcie->dev, fmt, timeout_us_min, timeout_us_max); + } + + /* Each unit in timeout register is 1/216,000,000 seconds */ + rval = 216 * timeout_us; + writel(rval, pcie->base + REG_OFFSET); +} + static int brcm_pcie_start_link(struct brcm_pcie *pcie) { struct device *dev = pcie->dev; @@ -1110,6 +1139,7 @@ static int brcm_pcie_start_link(struct brcm_pcie *pcie) return -ENODEV; } + brcm_config_completion_timeout(pcie); brcm_config_clkreq(pcie); if (pcie->gen)