Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp3772288pxt; Tue, 10 Aug 2021 10:59:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwpnR/lkji6wQR85yZ2zII8bq9ug0/ngDcIoxZ4pWLAyeIzZrFi4WsCdUYdPVjcnZwZR8KA X-Received: by 2002:a50:c88d:: with SMTP id d13mr6221781edh.334.1628618342397; Tue, 10 Aug 2021 10:59:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628618342; cv=none; d=google.com; s=arc-20160816; b=s2NSRixN/S5eO25DWij89qUl3v65qs+2ujetc1ZlmFqtJR9MBriy+zTEbn3BYawYPU 1wFDHOd1km6m+5NcqGVJkQlNYCi/73R+YK60eKBKfHRHsfpVO8Oao18qW7TikgCfpWk7 USQE1pMtew9A5CA0AtdUOKb5xRGtKnfvU7TGBakithPeSGoSGhaJ3DBHGMTP89VpxZAi ruEpQfZ+9sX+pFr7pAZoedLGz3sqgTim5zk66helWNuGvt2xF9enlhU+HwxOJ5La6kNu Fqs6xe4aDJ/e/PCXL/s0tUJSB9QbvnaaidI6+mPpqyPGO0trKLQ/VQWUcu3Eeruym4bR 6UCQ== 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=zVnag8fCaGK6Zbv8Pq/ZFKDlVAiDUKIRHkluaimIkKI=; b=Xz2O76NG8VsgZ2woYSbVc7gEB0fL25CVZz91EoQBikBmf2asLsyIsGaO8AyHO8k1V5 Mz2D8ZEmlqz+ULZfrJyy7mMMjFk5Qf2NPyQ1W70xEac84LM5lZXdIjz+4Y3wAKtjVFnm ugW6Tomjw3Z61pepBdQfS8oAN4amh04SKBvREoSxgkzREzZdlWddqZ1hXg+cx4Sm3/hZ CWPL0QVApK+MBj7umifDQz4pUN4onJMFmL9iYuaLUxhK/B6jXdGZ4a6wABU5b6sJLn63 HHLT+w6VdRgi2AMXpibNMLJMOS/KDg6bSVJyvL7033oYIZbG8pXz0S2N2h5OIQ7WM/KH uOEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=A3KRlmmA; 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 hq32si20335560ejc.264.2021.08.10.10.58.38; Tue, 10 Aug 2021 10:59:02 -0700 (PDT) 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=A3KRlmmA; 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 S232206AbhHJR4Y (ORCPT + 99 others); Tue, 10 Aug 2021 13:56:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:47970 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236737AbhHJRxW (ORCPT ); Tue, 10 Aug 2021 13:53:22 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 401DC6135D; Tue, 10 Aug 2021 17:43:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1628617435; bh=3Ggm+716gLtpYDSXl0NiCf7R5Lg1jHHIeN7PoqvitcQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A3KRlmmAnfMs8maa57mncBlzaYmnRundVN/mpqgV3opGJmcwvxkd1AyZywdu04KpI kIN5Xas56Sr7XxNWRxuxpUILLve70i4fErW2fyvGnDIVvKVdzK4RfW2jQ+APHFEkus O7Q4/cWqWRhb1PTx0oYxw9FuMu8lzeHMkF7hPwpw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Oleksij Rempel , Andrew Lunn , Florian Fainelli , Vladimir Oltean , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.13 056/175] net: dsa: qca: ar9331: reorder MDIO write sequence Date: Tue, 10 Aug 2021 19:29:24 +0200 Message-Id: <20210810173002.787653218@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210810173000.928681411@linuxfoundation.org> References: <20210810173000.928681411@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: Oleksij Rempel [ Upstream commit d1a58c013a5837451e3213e7a426d350fa524ead ] In case of this switch we work with 32bit registers on top of 16bit bus. Some registers (for example access to forwarding database) have trigger bit on the first 16bit half of request and the result + configuration of request in the second half. Without this patch, we would trigger database operation and overwrite result in one run. To make it work properly, we should do the second part of transfer before the first one is done. So far, this rule seems to work for all registers on this switch. Fixes: ec6698c272de ("net: dsa: add support for Atheros AR9331 built-in switch") Signed-off-by: Oleksij Rempel Reviewed-by: Andrew Lunn Reviewed-by: Florian Fainelli Reviewed-by: Vladimir Oltean Link: https://lore.kernel.org/r/20210803063746.3600-1-o.rempel@pengutronix.de Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/dsa/qca/ar9331.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/net/dsa/qca/ar9331.c b/drivers/net/dsa/qca/ar9331.c index ca2ad77b71f1..6686192e1883 100644 --- a/drivers/net/dsa/qca/ar9331.c +++ b/drivers/net/dsa/qca/ar9331.c @@ -837,16 +837,24 @@ static int ar9331_mdio_write(void *ctx, u32 reg, u32 val) return 0; } - ret = __ar9331_mdio_write(sbus, AR9331_SW_MDIO_PHY_MODE_REG, reg, val); + /* In case of this switch we work with 32bit registers on top of 16bit + * bus. Some registers (for example access to forwarding database) have + * trigger bit on the first 16bit half of request, the result and + * configuration of request in the second half. + * To make it work properly, we should do the second part of transfer + * before the first one is done. + */ + ret = __ar9331_mdio_write(sbus, AR9331_SW_MDIO_PHY_MODE_REG, reg + 2, + val >> 16); if (ret < 0) goto error; - ret = __ar9331_mdio_write(sbus, AR9331_SW_MDIO_PHY_MODE_REG, reg + 2, - val >> 16); + ret = __ar9331_mdio_write(sbus, AR9331_SW_MDIO_PHY_MODE_REG, reg, val); if (ret < 0) goto error; return 0; + error: dev_err_ratelimited(&sbus->dev, "Bus error. Failed to write register.\n"); return ret; -- 2.30.2