From patchwork Fri Apr 28 22:34:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 13226877 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 1A283C77B61 for ; Fri, 28 Apr 2023 22:36:18 +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=LxCtK/45oSfXuFyJIeO6aVaWqw7gLnJvoF7A7hRAYtI=; b=gf6qK3uGQHLPhx O1C/MtpqMAVkP+Qm/HRiW1i+VHrfOs2NkuMKPm2gYipb2qmv/xM9N9JKZpCK7E215vv3EY61lLc9r k3YcEsDE51h2qd/tnnJGVAEH4RHn4rYWgwjTQZ09G+RrEBmUIW/T1qi9GJQ2QTAc+xLDl7U+X2KL0 NrZhC/F0Y1tX+ACVvkrb698tjSHm4okxdgaW0YuztF8dHHPADcmbvEc92SKTKKKD5ytNB7oEw9THF HbYWxTSOZO/xAT6VogYKicwaqdWUm1rsSHXAqKcAAGm4gflRm76Waipr84adud9qhO2oNAF7hn4W3 qAfbEXj+jxjZHR4Vhx8A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1psWgh-00Bsdo-1J; Fri, 28 Apr 2023 22:35:35 +0000 Received: from mail-pg1-x52a.google.com ([2607:f8b0:4864:20::52a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1psWgO-00BsXi-1T; Fri, 28 Apr 2023 22:35:17 +0000 Received: by mail-pg1-x52a.google.com with SMTP id 41be03b00d2f7-518d325b8a2so312420a12.0; Fri, 28 Apr 2023 15:35:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682721316; x=1685313316; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=KlHfoAK9yIIL7Skn5B+cEJbm8dBEJYFGzxR8exxzgXQ=; b=Kb+u4fJA7dD3ma7mh7ur3/WOGuTpaYWQFbTJ15nPcFDNiF+ONXnzW8oq6ZHX1Vup+0 seIwnPvE87ivhg8uQliuz2f5wPrcotvoo2mge2XTb8+v/rh7BX4DbPsX3Ntin7c+h/ax rYjnbirkxtlMiXz8s4dV/dmhUNqFbDTx19EsQ6LDuSEHNn0qNQhhY+7i1KdWRjD/e6wC x+yFh30Qrk17VtQmIeqQIsHJayPMxkkXNya5vvQmc5OPTvW77dMwYGo5UoW8xoDF/i8x /OeK7BaMftDsattR2p3RpxgnYorlwGLUbLnwNxdrN428PAPyHXqA4LsKc5Mg+82N1XdV iLJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682721316; x=1685313316; 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=KlHfoAK9yIIL7Skn5B+cEJbm8dBEJYFGzxR8exxzgXQ=; b=k5lCvfKTBUv9yH58WG1/Dkv7HA3N4hbOiTEVI1adLprFM7ewaaop7GFlnqU3kQ8t3z hkQ29t39IKvc8Oyw0YQ2cJ3F+MI0E7sMsmdVbKFX5jTFnBFQhNLOp40hwuzeUjbThV6i fkS+9Srh9ilDS4MdFj0bnp25scfbFKh+yXrWe+if3Lk7xEzvRycl3TExV3xRoOU2FkIr aDsT144Wjr0WV64MaGi9UQy2BxKR+Pu9oTMJ8d+J5RbAsu0nM1QII35hvJKLet4mQV9D nxJ/E++zYjl7s5a3THz88gB0xdYUF41AjBhmVagxy3MJYyCDEspDV2hIYMOZZBGyxP8+ Xmhw== X-Gm-Message-State: AC+VfDw6biTa3gyFoTiYNhj2Z5PXn1wzmlYlndU6nCtZJYjgBR7TzZQz cYuwmS3BkIDkJi+QEkmz/IM= X-Google-Smtp-Source: ACHHUZ68ybGXSJgG5K8t8W9riO0/4ScMAw2d8sx0MAvypN9nDxB1x2uEHSKe4GewhEAxoXQFTg1YHA== X-Received: by 2002:a17:90b:1a81:b0:247:7def:236a with SMTP id ng1-20020a17090b1a8100b002477def236amr7109657pjb.34.1682721315980; Fri, 28 Apr 2023 15:35:15 -0700 (PDT) Received: from stbsrv-and-01.and.broadcom.net ([192.19.144.250]) by smtp.gmail.com with ESMTPSA id j8-20020a170902690800b001a1b66af22fsm13657847plk.62.2023.04.28.15.35.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Apr 2023 15:35:15 -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 v4 3/5] PCI: brcmstb: Set PCIe transaction completion timeout Date: Fri, 28 Apr 2023 18:34:57 -0400 Message-Id: <20230428223500.23337-4-jim2101024@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230428223500.23337-1-jim2101024@gmail.com> References: <20230428223500.23337-1-jim2101024@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230428_153516_502544_4523115E X-CRM114-Status: GOOD ( 13.17 ) 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-timeout-us" may be used to set a custom timeout value. Tested-by: Florian Fainelli 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 c4b076ea5180..c2cb683447ac 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)