From patchwork Thu Oct 6 22:03:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 13000773 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 455B6C4332F for ; Thu, 6 Oct 2022 22:05:07 +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=+ZFdbQbrmQNBPuK+SQ6PlCSaGLTcEd4jtV00BmyHfq0=; b=jh/Q8d7ERhzTzY El8xA9N5QglewzAdjjvpP9EKHQBwm3aPPCv2ZmNl2/4wJqToPEqz3qbEkgKZQivx50147nPP26Fy1 ZJDEJb9YFfxAd58M5KzbHdOyK+3h0pr/+uFgx5LBdI90d7hk6hJEJx6n7VrXzMCxenzhA8LzS6IR+ ZlbXOS3TQAfDD72/whesPvq8dDy7aNDIF3cXNf8u5P6BenjM/S6EOj+QhMqgpE9ucertLQzJkVxlT rYeGBikbKJEDZkcH9gnaUxsG4WCaxjZfjUahIbFx1tzA+jQUCWE4aR6jjo5ZdNUeWEApeXC5pnv9P qjQ3lOyZnFypNvTFWR6A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ogYyI-005WcT-7f; Thu, 06 Oct 2022 22:04:02 +0000 Received: from mail-ej1-x630.google.com ([2a00:1450:4864:20::630]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ogYxx-005WNt-Sa; Thu, 06 Oct 2022 22:03:43 +0000 Received: by mail-ej1-x630.google.com with SMTP id 13so7568481ejn.3; Thu, 06 Oct 2022 15:03:39 -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=BLYOB0a4x/X6dZd/1nZQ9gYDvNArvXo1VpvInak5Wn0=; b=J4Fk509zYUCWEF0CVRUktZHIEROIeoftJ9eHsCOkYd0x+SncnK69V4ioM0JGD4lCzJ Ae4ZX1XFbfVnSOohDaWUIEEaY4nipt4B1IeCvvqQ5c+UNx9mKwU29CD5Tdkhtv5yKN/I F1gs28aafnlENHgK8qWBn6ShaEinoKdmX/6K6HPYVFcbpwgQNGNsNEGnJRgtPXmWslkV 2cTKm/taL3/41xJRbCWrXHqa8TfF/EVVNzpd2gCqSb0axeNULSFLyZ6P0Ptrb7NbBfzj FqC2WI6CKNhOohrYgxKPfqJlrE21aCONGbWW2tKtj98jr9yEUGrsj57PULP1lDCiSKT/ oi0Q== 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=BLYOB0a4x/X6dZd/1nZQ9gYDvNArvXo1VpvInak5Wn0=; b=GuMCAUguN/+zPaFgR1/gevP2/euIxN7VUQav+pgmq5K/o7kUzqRQ4+QC9abzbTQ0zX ZrjCXzzYN10t27Uwf8Hn9+kiv5dXL9aKW92nw1hIFUAgxxMHsoOAu/K2Rs2f3i9YtBoh 0h6VRpVZfF3IfU2D3U8+YxRg6T7nwt4vfV9UgfMLbK6z1SZC1n5U7PtHAGmXsFdq6p8c DQRmamgbVHp5NF43dTNfqMeTrzckBEALCFSyDa9YoDBHSfphQAO4XPr7LlIxTW1DwY26 uUt3LfLpSfFSlNx0+yNcJfrKZV6KvHO1S8Od+zHgmFinj4+0BoZT1A8fg+dPsY/NoiSe 7sww== X-Gm-Message-State: ACrzQf1XoT6vlDhnf0NLhe/zlDhgSRRPDOBtADho29gISqU7VDmS9Rke vurGKJZ+xsfK3XuScP33aYM= X-Google-Smtp-Source: AMsMyM6xoPk32OflUxBn5euuJgnfF6SFYRYD2jnSaALoGLTWmUzpuPDH50kZ5SrEKJiGZtp1Cxzn0w== X-Received: by 2002:a17:907:7f93:b0:787:7fbc:8081 with SMTP id qk19-20020a1709077f9300b007877fbc8081mr1615376ejc.543.1665093818210; Thu, 06 Oct 2022 15:03:38 -0700 (PDT) Received: from stbsrv-and-01.and.broadcom.net ([192.19.144.250]) by smtp.gmail.com with ESMTPSA id f14-20020a17090631ce00b0078246b1360fsm241484ejf.131.2022.10.06.15.03.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Oct 2022 15:03:37 -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 v1 3/5] PCI: brcmstb: Replace status loops with read_poll_timeout_atomic() Date: Thu, 6 Oct 2022 18:03:19 -0400 Message-Id: <20221006220322.33000-4-jim2101024@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221006220322.33000-1-jim2101024@gmail.com> References: <20221006220322.33000-1-jim2101024@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221006_150341_946862_2A1DEBC2 X-CRM114-Status: GOOD ( 10.97 ) 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; } /*