From patchwork Thu Apr 6 12:46:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 13203265 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 8DAD1C76196 for ; Thu, 6 Apr 2023 12:47:32 +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=PnflkPeksqMImCO+UHdDTj4UFz4NffUx3u3W/NkNF2U=; b=AW+mLCaCs89i5p 3jFB4CW/EI9G/SH28133+hw3WC5QQg9kGI2ezJtYuGx0Td3Kq7TTwbY7k81uCFqhrYPf9iawMYTie +jbG+oH5FNDv+7EDvUv+hewcRhj3xfSuu9K5YTKxTEQMWOM6PI5JZ7HMtfcdclG4/5Yp4ZO0usbJp mi0G7F49qh14u37I0JlTMftI6SJHok4mMhQjiR7QN92Pbd1gls0me1C83fd+XMcgmqNiKdA8Z6eAk sreE3nQzGjO8z/9RbqvORZ1Xs5Ikub8a9quSJMpiMg0EXcikSooum2zJz0hpFwhKVUQ24uGkuZ3hJ o0cmeVL54PESXoOKgTpA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pkP0o-007Ig7-07; Thu, 06 Apr 2023 12:46:46 +0000 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pkP0k-007Idu-37; Thu, 06 Apr 2023 12:46:44 +0000 Received: by mail-wr1-x430.google.com with SMTP id i7so387281wrc.2; Thu, 06 Apr 2023 05:46:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680785201; x=1683377201; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=luFyciF8uhbYkGPNgpgaiPkjDSnlXlNp/qOa6qT6FH8=; b=nS5/rDNLtCzmL3//uFCtGvKctZZkKQgcK55vBT22aAEWLrCOaCGvl/dEggmaUE6AMe 2PtT/7Br51MXNCCcWURAAmaY+ys8sRgRcBL/zvr0DuF6medxqEQwZMecVebOhEET79+n HvM7eiimozHOoSLId0L1OMsSRizTCMsAF/VZwz9q+wrWxCCfS2K8ky4cpdbFaGa7U+oQ ecDEAfj79WcU9wHKgolrGUBaRUgOlSptGvOEcxq30kJw/3r5FMks0CL0VykongVUMqX1 VH/V+szpkYQYJ+nIQ8Tsm64wKvCw1Q7ZgBXUElbX3v6ggVZId3Nm0xgXBuEuhMsCUHps dL1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680785201; x=1683377201; 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=luFyciF8uhbYkGPNgpgaiPkjDSnlXlNp/qOa6qT6FH8=; b=ZVjbitf2kOhY8/cx/yeapsSMmNq/kAhVAjxD5n3l1ejubrwJIPnKuSKgOzkww9bfLH kt4Y74YUzkH6X7SJutzx4ZpXYh8XyZK1BokI63kjW0pSORJ9X5Nvjd1hO5dWh2ncOWQi ljS9VYXjqdBYTVg9j1ECuaB6SNxRM0dUv5HYS5c6Byyz7aY3P28J2XkAk/phMRBJDI0v QL3LcEx65v3druITvH9NDmEYmnbs/no2OxsOPzGVvTt4BHHlL+81yaBd03PPQCQUDOnl ZT37rRD5/7ERKsuSsVvtBdVnT6wHOKobm6MjPUUJ5EpENicgKMungW31nBGsPaeSVNkT nV7w== X-Gm-Message-State: AAQBX9dCqRUxkPCkHHE+g9DkGL7J5/jve/1GvHcj0AdpFMGptw93C4lY dFTURSlmkfSI0uhJzMr+kIQ= X-Google-Smtp-Source: AKy350bnsSUNhwYqeZVXUY4bJ7tb9Vvj4Rr9mIVgnCCCrtQ22Njl76/191eVPYwO2V87SHnsj1zFJQ== X-Received: by 2002:a5d:6885:0:b0:2c5:5687:5ed5 with SMTP id h5-20020a5d6885000000b002c556875ed5mr7088743wru.18.1680785200854; Thu, 06 Apr 2023 05:46:40 -0700 (PDT) Received: from stbsrv-and-01.and.broadcom.net ([192.19.144.250]) by smtp.gmail.com with ESMTPSA id n10-20020adff08a000000b002c5534db60bsm1686714wro.71.2023.04.06.05.46.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Apr 2023 05:46:39 -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 v1 3/3] PCI: brcmstb: Allow setting the completion timeout Date: Thu, 6 Apr 2023 08:46:24 -0400 Message-Id: <20230406124625.41325-4-jim2101024@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230406124625.41325-1-jim2101024@gmail.com> References: <20230406124625.41325-1-jim2101024@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230406_054643_008833_F469D46A X-CRM114-Status: GOOD ( 12.11 ) 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 completion timeout abort, we might as well extend the timeout limit. Further, different devices and systems may requires a larger or smaller amount for L1SS exit. Signed-off-by: Jim Quinlan --- drivers/pci/controller/pcie-brcmstb.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c index 129eee7bdbc1..92d78f4dfaae 100644 --- a/drivers/pci/controller/pcie-brcmstb.c +++ b/drivers/pci/controller/pcie-brcmstb.c @@ -1080,6 +1080,29 @@ 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 unsigned int REG_OFFSET = PCIE_RGR1_SW_INIT_1(pcie) - 8; + u32 timeout, timeout_msec = 1000; + u64 tmp64; + int ret; + + ret = of_property_read_u32(pcie->np, "brcm,completion-abort-msecs", + &timeout_msec); + + if (ret && ret != -EINVAL) + dev_err(pcie->dev, "bad 'brcm,completion-abort-msecs' prop\n"); + + /* Each unit in timeout register is 1/216,000,000 seconds */ + tmp64 = (u64)216000 * timeout_msec; + + /* Clamp the requested value before writing it */ + timeout = tmp64 > 0xffffffff ? 0xffffffff : tmp64; + timeout = timeout < 0xffff ? 0xffff : timeout; + writel(timeout, pcie->base + REG_OFFSET); +} + static int brcm_pcie_start_link(struct brcm_pcie *pcie) { struct device *dev = pcie->dev; @@ -1110,6 +1133,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)