From mboxrd@z Thu Jan 1 00:00:00 1970 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 36DE8C38145 for ; Tue, 6 Sep 2022 19:53:50 +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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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=HNtSkRctHkdgQILSyL5tmXolQj7AwrCRQX2IwL5QryQ=; b=IXQPC7cO/OF449 +5j4666wSsZiOWJRwQE3qJH06jq1OGu7nEgXlHOx2dhsszOMXaZkyP5tCJA4EsfrG/au7Zqv2bque K/Rx+JLQRm4yEDebQn/mHX7Pc4oZl1GhydZc09/7wijWgB9ZfJByfYWdlg/KsIEu00KbsHxXZwR/U mGdZh56giFkD+jlE8WeMKlby2zhuC9I5yemxxwy12UQ63rMHQ9Gvs7Va2zOB9cJ7JcewKKQsxBE+B Hkodwc7K3jSyMLjEybcKqTBDhZW4EDbNQEtvYI3sWBh+Q2mOJhw1xpul+M7Vaez7D1/NUq7veT6xE PzXOkkQaUQhbwVDaXRlw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVecc-00Gt5h-MP; Tue, 06 Sep 2022 19:52:35 +0000 Received: from mail-ej1-x634.google.com ([2a00:1450:4864:20::634]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVecZ-00Gt25-Am for linux-arm-kernel@lists.infradead.org; Tue, 06 Sep 2022 19:52:32 +0000 Received: by mail-ej1-x634.google.com with SMTP id bj12so25606437ejb.13 for ; Tue, 06 Sep 2022 12:52:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=1VmPA5Yq8eTH/6a8GLeRpEEPUlpUiovS+eHf396Ag4g=; b=fAEZWrlW3WNegmJlRFl5z4yJJNGBDMHOlL8r6C0EeIaNM/067+srYLvfeOAtwtihYf 3UxoQg6Lw4seebei0SaHQnYlb947cZAXMTcplsL63gt0t2KsN7OGNCmh6HXh0xHMAOwS vLEB4QJhnmMdFnAJfVxE/h0yXpyjffrmM+LGKA+vhIm7kwA0GHIA7GdMIOBVFH9wzkUq j+SXUxSv9QsiOuy5eRxsFuJEuxsVJkjQq9AQPlqYxUhEpfLWD29XFbFQSot7nyySSg0Z slO2S8jGDSFLx7yGuwV6ZaLoihH3bq4KGOaglNRJLR8/GnJdZMmum0vTmDHwSqVjwlA8 HAuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=1VmPA5Yq8eTH/6a8GLeRpEEPUlpUiovS+eHf396Ag4g=; b=cOcTfLhQiRYzewcxvoNOF77JjGfk1iohgSn/GICwV2NCci+6MpGjzD22aJJJ/HjPXo YZeVEs2c5kjRoqdwSuckc1Lbnrui0Lrl26wjhrw9YaXM/RA8qDo9xbJWtqqOkArwTb60 PVy6eWH/WaTTLfhC+BSYqDWcZZrLVXfl8uDE0Cqekp1XWc+NEEgkBvdY/RpLaYJUnZdh khqcLyHfRWNtJohRJMzGSFY8EfF57vMzKZXYsTtfy0+QzDAl4HxKOupxA2kFYc7PbTuU ifoMjZSfe/9jf1JnqJFIAIsRbE9VZPgMta8eCawgFoAmKcLkcq4mZ60b38f7GXlJDps6 /EJQ== X-Gm-Message-State: ACgBeo3rBDM1Y+xsCG4wyBfhJIhrptK6TcpB/oyoZ27vGsEDxeWDoR4K h+CI8UwIidCzhy66eWFeXN8= X-Google-Smtp-Source: AA6agR6l9+2gcUu/mhmRnnWa80cHCNMhpaeUYeFi2zZRQMHUqum76qUrEMPtgl3MaTjDFRyJM6+y3Q== X-Received: by 2002:a17:907:97c1:b0:741:a098:1703 with SMTP id js1-20020a17090797c100b00741a0981703mr74480ejc.216.1662493946813; Tue, 06 Sep 2022 12:52:26 -0700 (PDT) Received: from kista.localnet (82-149-1-172.dynamic.telemach.net. [82.149.1.172]) by smtp.gmail.com with ESMTPSA id r9-20020a1709061ba900b0073dd99a0febsm7115788ejg.188.2022.09.06.12.52.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 12:52:25 -0700 (PDT) From: Jernej =?utf-8?B?xaBrcmFiZWM=?= To: linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, qianfanguijin@163.com Cc: Maxime Ripard , Chen-Yu Tsai , linux-arm-kernel@lists.infradead.org, Evgeny Boger , qianfan Zhao Subject: Re: [PATCH 1/2] drivers: net: mdio-sun4i: Speedup mdio read and write Date: Tue, 06 Sep 2022 21:52:24 +0200 Message-ID: <4737709.GXAFRqVoOG@kista> In-Reply-To: <20220906075616.21347-1-qianfanguijin@163.com> References: <20220906075616.21347-1-qianfanguijin@163.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220906_125231_461960_9319DAE0 X-CRM114-Status: GOOD ( 21.37 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Dne torek, 06. september 2022 ob 09:56:15 CEST je qianfanguijin@163.com napisal(a): > From: qianfan Zhao > > msleep(1) on my board takes about 30ms, and it is too long to accept. > Use read_poll_timeout to speedup. > > Signed-off-by: qianfan Zhao > --- > drivers/net/mdio/mdio-sun4i.c | 29 ++++++++++++----------------- > 1 file changed, 12 insertions(+), 17 deletions(-) > > diff --git a/drivers/net/mdio/mdio-sun4i.c b/drivers/net/mdio/mdio-sun4i.c > index f798de3276dc..168e2a375535 100644 > --- a/drivers/net/mdio/mdio-sun4i.c > +++ b/drivers/net/mdio/mdio-sun4i.c > @@ -26,8 +26,6 @@ > #define EMAC_MAC_MIND_REG (0x10) > #define EMAC_MAC_SSRR_REG (0x14) > > -#define MDIO_TIMEOUT (msecs_to_jiffies(100)) > - > struct sun4i_mdio_data { > void __iomem *membase; > struct regulator *regulator; > @@ -36,8 +34,7 @@ struct sun4i_mdio_data { > static int sun4i_mdio_read(struct mii_bus *bus, int mii_id, int regnum) > { > struct sun4i_mdio_data *data = bus->priv; > - unsigned long timeout_jiffies; > - int value; > + int ret, tmp, value; > > /* issue the phy address and reg */ > writel((mii_id << 8) | regnum, data->membase + EMAC_MAC_MADR_REG); > @@ -45,12 +42,11 @@ static int sun4i_mdio_read(struct mii_bus *bus, int > mii_id, int regnum) writel(0x1, data->membase + EMAC_MAC_MCMD_REG); > > /* Wait read complete */ > - timeout_jiffies = jiffies + MDIO_TIMEOUT; > - while (readl(data->membase + EMAC_MAC_MIND_REG) & 0x1) { > - if (time_is_before_jiffies(timeout_jiffies)) > - return -ETIMEDOUT; > - msleep(1); > - } > + ret = read_poll_timeout(readl, tmp, (tmp & 1) == 0, > + 20, 10000, false, > + data->membase + EMAC_MAC_MIND_REG); You should use readl_poll_timeout() instead, as instructed by documentation. Additionally, are you sure about both delay parameters? They are both much smaller than in original code. Same comments apply to patch 2. Best regards, Jernej > + if (ret < 0) > + return ret; > > /* push down the phy io line */ > writel(0x0, data->membase + EMAC_MAC_MCMD_REG); > @@ -64,7 +60,7 @@ static int sun4i_mdio_write(struct mii_bus *bus, int > mii_id, int regnum, u16 value) > { > struct sun4i_mdio_data *data = bus->priv; > - unsigned long timeout_jiffies; > + int ret, tmp; > > /* issue the phy address and reg */ > writel((mii_id << 8) | regnum, data->membase + EMAC_MAC_MADR_REG); > @@ -72,12 +68,11 @@ static int sun4i_mdio_write(struct mii_bus *bus, int > mii_id, int regnum, writel(0x1, data->membase + EMAC_MAC_MCMD_REG); > > /* Wait read complete */ > - timeout_jiffies = jiffies + MDIO_TIMEOUT; > - while (readl(data->membase + EMAC_MAC_MIND_REG) & 0x1) { > - if (time_is_before_jiffies(timeout_jiffies)) > - return -ETIMEDOUT; > - msleep(1); > - } > + ret = read_poll_timeout(readl, tmp, (tmp & 1) == 0, > + 20, 10000, false, > + data->membase + EMAC_MAC_MIND_REG); > + if (ret < 0) > + return ret; > > /* push down the phy io line */ > writel(0x0, data->membase + EMAC_MAC_MCMD_REG); > -- > 2.25.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel