Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp3765091pxt; Tue, 10 Aug 2021 10:47:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJvT+EPTGXmfmVftt6mvXlOgV8NYY7Kie7eSdKYojV1LpuRehxahaBdM34jGWR/l6ul1WB X-Received: by 2002:a02:cac9:: with SMTP id f9mr17161279jap.104.1628617657565; Tue, 10 Aug 2021 10:47:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628617657; cv=none; d=google.com; s=arc-20160816; b=t//Mvn2NIk8oFuVFz1a6J9ZWV5c5hb15d8QXzeCJBJv0ysHZ4XhTDtt+hc8hlaWRNV QOqkd1/QInwYsDMCwsbBDLLR0N8h3zVbLK/+ajC9myIdOtJfmIE6NmS79YKMAd3Ul7xS RLCUc+sR5NjZ8KiRgD+JSSUvQVwdsG8bNr1FIhtModyR7ctD8RFj0VgrX11LVwIQfYe3 5bM2e2ypmvqgCf8C9m4P5QQC6gsoWJjG4lktHOyERQ5AM7GwCwec4JPoCpte85FPVP38 inIismBbVdzT9lOC6VYohXc6/d2f7S0H0GBJ4/aeHy6D4DPXhpixSV7zvRwqAN5VGyND 4oAA== 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=HjD/sllQuej42XtbQS9pwK18cG9YcrNuALrkxJ6BVqM=; b=my8MkLbwr+ctf2mYLtucUQ7b8cIPV4/F/oMFcrn8xl/1KZtuLkjlrWc0JSaZN0R7EL 4Tuklqz/VKt0LwGs0EQuZ6dbcTh2ypW3ydLRSK+4aEE0YnlKbSIwqQi0riHCZuybOYgJ TiXxZm8kbS605/6h4nKQ4DbinsyKE7WVsgbpaZmhLSr95qzDrGWtJ0wIHnlTDmPgOVPn 0tHDwD+F2nSVQ4mu0+IWpk714n7riGg+Z4tXMCoz3iLMpb4ZNNJK/gd1YMoEISN2P+3m ZAPjm1SxnIu31jDt4KaMjcJDjv/b1F/AJjv0SupxpAB3hfCRW+h2GU8fjJlKG+bDvC1u o99A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="qZLIe5/1"; 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 r17si21453108iog.96.2021.08.10.10.47.24; Tue, 10 Aug 2021 10:47:37 -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="qZLIe5/1"; 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 S232977AbhHJRrF (ORCPT + 99 others); Tue, 10 Aug 2021 13:47:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:36322 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235974AbhHJRoU (ORCPT ); Tue, 10 Aug 2021 13:44:20 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id ED0A161078; Tue, 10 Aug 2021 17:39:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1628617171; bh=RxHK1u20b/F8+DvhuvxB1aZdwvVr2uSLvIftHo8/y8U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qZLIe5/1YKmd6k5a0hGp+J0cvl2+ysaTm+Zc/yVwB6qshCMyCYbCqC4sVltItU/x/ AdoRTTDe/4BMQX/vne0m37v+VhV69jC4reRnOb+Y7QBzTZdio9KtZRb87z53g/jqHr LqhwTkT8h3lYyCjueYkYV7XxExZosG/dRbZ9U/YE= 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.10 042/135] net: dsa: qca: ar9331: reorder MDIO write sequence Date: Tue, 10 Aug 2021 19:29:36 +0200 Message-Id: <20210810172957.113381223@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210810172955.660225700@linuxfoundation.org> References: <20210810172955.660225700@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 4d49c5f2b790..661745932a53 100644 --- a/drivers/net/dsa/qca/ar9331.c +++ b/drivers/net/dsa/qca/ar9331.c @@ -689,16 +689,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