From patchwork Tue Oct 11 18:42:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 13004257 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 90A38C433F5 for ; Tue, 11 Oct 2022 18:43:53 +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=G0/3jj+ovRlQahBfNDCY5VEF4MoBeEsbPlhpd728kvM=; b=4IAAwc942uYT7W mQH3ePxXxDBGWd2XtlkZWQrIh6sA4fuOyqBe26yA7K/RR+3Wf6rLhpFnK1VKCLhEE69jWDnvtuGfY JuMoL8MWOjrjaMr3dmqVofEUI2qkVi34ZUrL9fpXBgWj8glvLZ/3UccL7Y7AQBw2Ki9/ccy4AMn02 LUeHpcaXKBDXrFoXzPsSMyfXFKiagYSQkwV4QgYLseE9RWEcUOSXizR5dD9lOOY26NR6Q5qxiSKbM ITmz89hYkzkrEXmN8b2HdC7ls80bhjIRYBfR29d0uvf9gUENp6hOJlup7gBR+jmxcdDdoogtZSikv 63cBQybMUd6zBBidxEVA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oiKDI-005TKY-1F; Tue, 11 Oct 2022 18:42:48 +0000 Received: from mail-qk1-x732.google.com ([2607:f8b0:4864:20::732]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oiKCq-005TB5-62; Tue, 11 Oct 2022 18:42:22 +0000 Received: by mail-qk1-x732.google.com with SMTP id o2so1883564qkk.10; Tue, 11 Oct 2022 11:42:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=yC68PwSujcmdozdXRLObvH5ia1utZiSGZZx8tkWQRwM=; b=BM856Tof1maVbKADbUoeep+v/Kh8Xs4qIGjPkd1Sxt3W/8Y6ieF7VVHMspdh6BFj6G iXG0PCB0OrR+maaj9i05cbmgMrUiZ2Yv2KMwekF2Xr7SwJ5Xu5raHGepeHyp3GCCYAiZ PWgBi8HaDT6cWz1658v8xfGY8Yw//RrgNDoOwgB5eTmtFhNiN91sht2mLWf1qJ6CNpOy daMwLlGgcLOAw6XYIgAZZ+bdCx0AruOla8hAtt/N/HLDEEzgvtt58sv1osYo5Jr2k04o C9MHMrsCz4sa5JnMTMiDonVFbcyD/IdAgZGUBbqxwwMljnoY1n6cUvkpvp6ZEZb1uXmz 1Dqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=yC68PwSujcmdozdXRLObvH5ia1utZiSGZZx8tkWQRwM=; b=BojHPn2fxrDldMWUXSXW+73ojpS5sTDaeukcSbgdnzIz1wdVS9CUpP3aTRwZDQyKDu 92XEuvtUYCqwttnsoJvbkmpp/Y4ZSonr9J5g+maoLYtJik/5T02xhBJ031Utv3n15Eud rNVrkHc3OKp0oMf1cG9PfqAtVNXSsQlN5C0jIMio95VKefsza0hN5h6q5ikofq24K2TA eRsBjIL1rB8VaWCcruDOzydWGQRUXiSxdKuascXPqoXMWLcDUHALb8hPcg6KveMscGfi +NLV4FAdMWtXL3xiNm+QQ/OSAKN1BWbRNr++EeXuCf1DjfNh3IDnwBtcjSdLKsSgjaK1 2/pw== X-Gm-Message-State: ACrzQf1X+JhctZxwcq48ot58L6oMHh0RTi5xWkwX6rNEh/tO4tuqcCZm VMVgcpq8/0UIOSfL3a502EAmIpQywaM= X-Google-Smtp-Source: AMsMyM4Vf6sWyq8Gx07MlfotRqmjQhuQIEe0h6hqEI4mPD99OXt3GmtehfAZuvdtbMJqLkVQo7HZWw== X-Received: by 2002:a05:620a:12fb:b0:6ee:79f2:3716 with SMTP id f27-20020a05620a12fb00b006ee79f23716mr3676940qkl.348.1665513738030; Tue, 11 Oct 2022 11:42:18 -0700 (PDT) Received: from stbsrv-and-01.and.broadcom.net ([192.19.144.250]) by smtp.gmail.com with ESMTPSA id fc8-20020a05622a488800b003938a65479bsm10961732qtb.10.2022.10.11.11.42.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 11:42:17 -0700 (PDT) From: Jim Quinlan To: linux-pci@vger.kernel.org, Nicolas Saenz Julienne , Bjorn Helgaas , Lorenzo Pieralisi , Cyril Brulebois , bcm-kernel-feedback-list@broadcom.com, jim2101024@gmail.com, james.quinlan@broadcom.com Cc: Florian Fainelli , Lorenzo Pieralisi , Rob Herring , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , 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/5] PCI: brcmstb: Replace status loops with read_poll_timeout_atomic() Date: Tue, 11 Oct 2022 14:42:08 -0400 Message-Id: <20221011184211.18128-4-jim2101024@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221011184211.18128-1-jim2101024@gmail.com> References: <20221011184211.18128-1-jim2101024@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221011_114220_255343_3D201AED X-CRM114-Status: GOOD ( 11.09 ) 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 It would be nice to replace the PCIe link-up loop as well but there are too many uses of this that do not poll (and the read_poll_timeout uses "timeout==0" to loop forever). Signed-off-by: Jim Quinlan Acked-by: Florian Fainelli --- drivers/pci/controller/pcie-brcmstb.c | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c index 39b545713ba0..c7210cec1f58 100644 --- a/drivers/pci/controller/pcie-brcmstb.c +++ b/drivers/pci/controller/pcie-brcmstb.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -302,42 +303,34 @@ static u32 brcm_pcie_mdio_form_pkt(int port, int regad, int cmd) /* negative return value indicates error */ static int brcm_pcie_mdio_read(void __iomem *base, u8 port, u8 regad, u32 *val) { - int tries; u32 data; + int err; writel(brcm_pcie_mdio_form_pkt(port, regad, MDIO_CMD_READ), base + PCIE_RC_DL_MDIO_ADDR); readl(base + PCIE_RC_DL_MDIO_ADDR); - - data = readl(base + PCIE_RC_DL_MDIO_RD_DATA); - for (tries = 0; !MDIO_RD_DONE(data) && tries < 10; tries++) { - udelay(10); - data = readl(base + PCIE_RC_DL_MDIO_RD_DATA); - } - + err = readl_poll_timeout_atomic(base + PCIE_RC_DL_MDIO_RD_DATA, data, + MDIO_RD_DONE(data), 10, 100); *val = FIELD_GET(MDIO_DATA_MASK, data); - return MDIO_RD_DONE(data) ? 0 : -EIO; + + return err; } /* negative return value indicates error */ static int brcm_pcie_mdio_write(void __iomem *base, u8 port, u8 regad, u16 wrdata) { - int tries; u32 data; + int err; writel(brcm_pcie_mdio_form_pkt(port, regad, MDIO_CMD_WRITE), base + PCIE_RC_DL_MDIO_ADDR); readl(base + PCIE_RC_DL_MDIO_ADDR); writel(MDIO_DATA_DONE_MASK | wrdata, base + PCIE_RC_DL_MDIO_WR_DATA); - data = readl(base + PCIE_RC_DL_MDIO_WR_DATA); - for (tries = 0; !MDIO_WT_DONE(data) && tries < 10; tries++) { - udelay(10); - data = readl(base + PCIE_RC_DL_MDIO_WR_DATA); - } - - return MDIO_WT_DONE(data) ? 0 : -EIO; + err = readw_poll_timeout_atomic(base + PCIE_RC_DL_MDIO_WR_DATA, data, + MDIO_WT_DONE(data), 10, 100); + return err; } /*