Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3971769pxb; Tue, 25 Jan 2022 00:19:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJxu2hDgZaTyeCCztOB8IAQeaydutGynSb2xV8YIwaxl3bNJF1/KJX1/dPU9pcUmBnfFvwq4 X-Received: by 2002:a05:6402:2802:: with SMTP id h2mr8238304ede.221.1643098752671; Tue, 25 Jan 2022 00:19:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643098752; cv=none; d=google.com; s=arc-20160816; b=cn8ac0qYgVZXs7z8TIyZjWPPGPOo/1gwOQ9sOtYoXoQhlrYmNH6pbzxju1Pm2GuTKm Oq8amjOB1rXN9ih1mEwFENQkT6/mE1VD83HjW+X5C65BLuzpuSEjy2LeB5fcfIM60/tU /Xtd4aEXxt3ENzZqPdsDi4e626MY25NZ2jiJaphIea360yVU/9HJj/tnKekZhTh/NW6b 74sFTPNwY41VtdNYf/1rvHq5u2um38ZbT4lerxSa4UAnmQ+D0EPI4ItfyWBlcrJHqoB3 EiIu3pdnqmO2NXIEdQkoPXMGHuxtWLPTPeZCX8EI8W+LLWLIstIkEfjDc1E8Y0+nLaLy t8Iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ZGJb8IfC9GXFKS6uaMJr0fJZCoo0irnGuPfuhjtCGCQ=; b=efdFc9rCTwyalIALduoygAr8AG1DvaazpJgCBKChjciJaY/BhwTmVMBrY12tUFEPav g8oo3NWyBJzuDCK9OnrAEVYVcqcbif/lrTF5bkHqwtgKuVaKtRM+eIslBBTVEmM5DfnP 7BBiwBNY9xBzZ6Tnka1SLB72zTJVBLT1JDNsi6PhwnxMmkypIxyVopxPXLzW4Yen/mS9 GMi4nJfFumr34GxXM9SGt+XfLz823qiID6lo1J7C56N3+HphK4JK2iir8JsbZqbAC4Nl xCYlVbMcuh2ctAF67M4whH+HttTa2dw425yzdmDEXZe23QbRRSNbT1l9ZBSd6F9WfnX6 p/2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=eeYzd6n1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id go12si9221445ejc.678.2022.01.25.00.18.48; Tue, 25 Jan 2022 00:19:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=eeYzd6n1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S3412866AbiAYAh5 (ORCPT + 99 others); Mon, 24 Jan 2022 19:37:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2364080AbiAXXqp (ORCPT ); Mon, 24 Jan 2022 18:46:45 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E366C061343; Mon, 24 Jan 2022 13:42:13 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D109C61525; Mon, 24 Jan 2022 21:42:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C81BCC340E4; Mon, 24 Jan 2022 21:42:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643060532; bh=fMqlVqRgLmA4ReuZh+yK8Z44tWXTuoUX2Gh4m1hyshQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eeYzd6n16O0odMWFRbzHeDIUEuBmTObB4u1DwyOQsU+laH7Bu+KR8Q0LdpZacyhH+ +/9n7r6SlUs3uJQHRzcnTM9AHxX9YB6Mxz5M5wwlkq6RQkVlomJvjQUvshtDjhSbL5 Y1N5CzoPIyXVrf74ygWsilq2DE/KjrLaaNqUcTqA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tobias Waldekranz , Andrew Lunn , Jakub Kicinski Subject: [PATCH 5.16 0947/1039] net/fsl: xgmac_mdio: Add workaround for erratum A-009885 Date: Mon, 24 Jan 2022 19:45:36 +0100 Message-Id: <20220124184157.125419120@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tobias Waldekranz commit 6198c722019774d38018457a8bfb9ba3ed8c931e upstream. Once an MDIO read transaction is initiated, we must read back the data register within 16 MDC cycles after the transaction completes. Outside of this window, reads may return corrupt data. Therefore, disable local interrupts in the critical section, to maximize the probability that we can satisfy this requirement. Fixes: d55ad2967d89 ("powerpc/mpc85xx: Create dts components for the FSL QorIQ DPAA FMan") Signed-off-by: Tobias Waldekranz Reviewed-by: Andrew Lunn Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/freescale/xgmac_mdio.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) --- a/drivers/net/ethernet/freescale/xgmac_mdio.c +++ b/drivers/net/ethernet/freescale/xgmac_mdio.c @@ -51,6 +51,7 @@ struct tgec_mdio_controller { struct mdio_fsl_priv { struct tgec_mdio_controller __iomem *mdio_base; bool is_little_endian; + bool has_a009885; bool has_a011043; }; @@ -186,10 +187,10 @@ static int xgmac_mdio_read(struct mii_bu { struct mdio_fsl_priv *priv = (struct mdio_fsl_priv *)bus->priv; struct tgec_mdio_controller __iomem *regs = priv->mdio_base; + unsigned long flags; uint16_t dev_addr; uint32_t mdio_stat; uint32_t mdio_ctl; - uint16_t value; int ret; bool endian = priv->is_little_endian; @@ -221,12 +222,18 @@ static int xgmac_mdio_read(struct mii_bu return ret; } + if (priv->has_a009885) + /* Once the operation completes, i.e. MDIO_STAT_BSY clears, we + * must read back the data register within 16 MDC cycles. + */ + local_irq_save(flags); + /* Initiate the read */ xgmac_write32(mdio_ctl | MDIO_CTL_READ, ®s->mdio_ctl, endian); ret = xgmac_wait_until_done(&bus->dev, regs, endian); if (ret) - return ret; + goto irq_restore; /* Return all Fs if nothing was there */ if ((xgmac_read32(®s->mdio_stat, endian) & MDIO_STAT_RD_ER) && @@ -234,13 +241,17 @@ static int xgmac_mdio_read(struct mii_bu dev_dbg(&bus->dev, "Error while reading PHY%d reg at %d.%hhu\n", phy_id, dev_addr, regnum); - return 0xffff; + ret = 0xffff; + } else { + ret = xgmac_read32(®s->mdio_data, endian) & 0xffff; + dev_dbg(&bus->dev, "read %04x\n", ret); } - value = xgmac_read32(®s->mdio_data, endian) & 0xffff; - dev_dbg(&bus->dev, "read %04x\n", value); +irq_restore: + if (priv->has_a009885) + local_irq_restore(flags); - return value; + return ret; } static int xgmac_mdio_probe(struct platform_device *pdev) @@ -287,6 +298,8 @@ static int xgmac_mdio_probe(struct platf priv->is_little_endian = device_property_read_bool(&pdev->dev, "little-endian"); + priv->has_a009885 = device_property_read_bool(&pdev->dev, + "fsl,erratum-a009885"); priv->has_a011043 = device_property_read_bool(&pdev->dev, "fsl,erratum-a011043");