From patchwork Mon Sep 21 06:57:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuanhong Guo X-Patchwork-Id: 1368089 X-Patchwork-Delegate: gch981213@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.openwrt.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=VGQSUZaD; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=ia+Y0n12; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BvwMl2w2Kz9sSn for ; Mon, 21 Sep 2020 17:01:22 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=HoST4fjiCaeTybz9s4yAnCb531KyPPjBzDmhQeRPCbA=; b=VGQSUZaD4EhxoZ/5qxzWA+IqF6 i5Qwfd9EAfX0k8HkuMFcFf4d/WuTEY8XAokgRqatvLrxqNmiyZOl07OYD5O1zAAFHRb8nSu35eL6i eOq+Yy90zlwWGa+nd+xBDjFDSqrOtXqDEGVToHaqAWZIn3EsGtGKckN9NFCVBD0hL/aBING6g9joJ oN0aGbcjKHXZ3bp7bFFtOu1zhbsIC+e3ynK8zuMQL3hwvSdb3T4v0vjUPIgpjEogz90ppvpH0m3Wp PXQMwXYBu2hH2luqKoqlJ62j0RgF8/ZmhyowYwzPCcxsvkmvOraRYfHxmuYmUcteVjTBNussrxmTw rBcr4Jmg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kKFmz-0003sX-8x; Mon, 21 Sep 2020 06:59:05 +0000 Received: from util-01.infra.openwrt.org ([46.101.232.90]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kKFmt-0003qM-V2 for openwrt-devel@lists.openwrt.org; Mon, 21 Sep 2020 06:59:01 +0000 Received: from mail-pf1-f195.google.com ([209.85.210.195]) by util-01.infra.openwrt.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1kKFmp-0003SB-82 for openwrt-devel@openwrt.org; Mon, 21 Sep 2020 02:58:55 -0400 Received: by mail-pf1-f195.google.com with SMTP id l126so8451086pfd.5 for ; Sun, 20 Sep 2020 23:58:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=YD8g3FGSnf24qBA2J3Hm0tYmFw6lvTrJ2SV4360moFI=; b=ia+Y0n12W5PpnNEKzLCHw23xodlXb8OdFtxCMRQjLZi1RVKmwl9IJjaGWKdkinjiPp mXlxwNMq3aPXcdfZ8Cxogof/+bu2bBjhPaJ27//u9zP3rRzcnhSfCBHZnfideLw7PGEI a1ZpUgCSFpOBwJNNkZoY14HGKioyKiZ82Df5DqBiJBLjkCDVCXIdhB8J/iTCdydI8qIZ 8pa8VGk9/cWlHvXOO7v/sD4faj0IvBE4U7MI7PjWkpD5YHFOyBiVr+hhtkStD1DT2dpy xqYL1q9Iw9TuXucWmRDvzM9whhjOcWBFdem20KnDw8aL9Xz6xUab3T75ZVUtdZOb996a KA5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=YD8g3FGSnf24qBA2J3Hm0tYmFw6lvTrJ2SV4360moFI=; b=U8xtA/XfOPtO5GTwr/dy34uL5sGCtvghCkrrkgjnZfe1wcGBx6sNHgmIHv/cudpfvT XISqJhh/nrauBPLzcsZyp4UizSpmykEKqlZKKOpHSiZCCTeKuadcBOWkS8JCBEjulLHO AL2ACpuD67lneRPOq5haapYb8RwzqO27jBC81+t3YUUnQNoe5UbIy10K23/3gU8t/Llf 8GlkM6urW4tANlZvTJXcYWUjj6Lf1vKS72ZTu0T+EuFlB18FvQBFqzJTvHuPHbRpUadN kijT8MNYUPxRiBvkdjKqbHbiOYPOsqrQDGu0J7SZgg6ZO7O8eZsznuIcMqXth+ZHGdEp +8iw== X-Gm-Message-State: AOAM5317ileay9kqr3VuastF84PTKLyWA2SKsC7Dxa/ff7JmFw8EpSfO ULz2HeEwm4c3vCSeRvNRpNt89lqyx5cqXQ== X-Google-Smtp-Source: ABdhPJylrOhBWOuag2sGxvvDUyfPnvhJ7Kt1WwKgeM9UCT7pHjhLgGVMmwWOwV1yv1HugMIZ8ooH0A== X-Received: by 2002:a17:902:c281:b029:d2:2988:4906 with SMTP id i1-20020a170902c281b02900d229884906mr1973200pld.82.1600671473172; Sun, 20 Sep 2020 23:57:53 -0700 (PDT) Received: from guoguo-omen.lan ([156.96.148.94]) by smtp.gmail.com with ESMTPSA id m14sm10557009pfo.202.2020.09.20.23.57.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Sep 2020 23:57:52 -0700 (PDT) From: Chuanhong Guo To: openwrt-devel@openwrt.org Subject: [PATCH] ath79: ar8216: make switch register access atomic Date: Mon, 21 Sep 2020 14:57:44 +0800 Message-Id: <20200921065744.491098-1-gch981213@gmail.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 X-Spam-Score: -1.8 (-) X-Spam-Report: Spam detection software, running on the system "util-01.infra.openwrt.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see jo@mein.io for details. Content preview: reg accesses on integrated ar8229 sometimes fails. As a result, phy read got incorrect port status and wan link goes down and up mysteriously. After comparing ar8216 with the old driver, these local_i [...] Content analysis details: (-1.8 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [209.85.210.195 listed in wl.mailspike.net] 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit (gch981213[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (gch981213[at]gmail.com) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200921_025900_183504_54CF17DF X-CRM114-Status: GOOD ( 44.50 ) X-Spam-Score: 1.3 (+) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (1.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [46.101.232.90 listed in list.dnswl.org] 2.6 RCVD_IN_SBL RBL: Received via a relay in Spamhaus SBL [156.96.148.94 listed in zen.spamhaus.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [gch981213[at]gmail.com] 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit [gch981213[at]gmail.com] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Chuanhong Guo Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org reg accesses on integrated ar8229 sometimes fails. As a result, phy read got incorrect port status and wan link goes down and up mysteriously. After comparing ar8216 with the old driver, these local_irq_save/restore calls are the only meaningful differences I could find and it does fix the issue. The same changes were added in svn r26856 by Gabor Juhos: ar71xx: ag71xx: make switch register access atomic As I can't find the underlying problem either, this hack is broght back to fix the unstable link issue. This hack is only suitable for ath79 mdio and may easily break the driver on other platform. Limit it to ath79-only as a target patch. Fixes: FS#2216 Fixes: FS#3226 Signed-off-by: Chuanhong Guo Tested-by: Adrian Schmutzler Acked-by: Adrian Schmutzler --- .../930-ar8216-make-reg-access-atomic.patch | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 target/linux/ath79/patches-5.4/930-ar8216-make-reg-access-atomic.patch diff --git a/target/linux/ath79/patches-5.4/930-ar8216-make-reg-access-atomic.patch b/target/linux/ath79/patches-5.4/930-ar8216-make-reg-access-atomic.patch new file mode 100644 index 0000000000..42f3305195 --- /dev/null +++ b/target/linux/ath79/patches-5.4/930-ar8216-make-reg-access-atomic.patch @@ -0,0 +1,61 @@ +From b3797d1a92afe97c173b00fdb7824cedba24eef0 Mon Sep 17 00:00:00 2001 +From: Chuanhong Guo +Date: Sun, 20 Sep 2020 01:00:45 +0800 +Subject: [PATCH] ath79: ar8216: make switch register access atomic + +due to some unknown reason these register accesses sometimes fail +on the integrated switch without this patch. + +THIS ONLY WORKS ON ATH79 AND MAY BREAK THE DRIVER ON OTHER PLATFORMS! +The mdio bus on ath79 works in polling mode and doesn't rely on +any interrupt. This patch breaks the driver on any mdio master +with interrupts used. + +--- +--- a/drivers/net/phy/ar8216.c ++++ b/drivers/net/phy/ar8216.c +@@ -253,12 +253,14 @@ ar8xxx_mii_write32(struct ar8xxx_priv *p + u32 + ar8xxx_read(struct ar8xxx_priv *priv, int reg) + { ++ unsigned long flags; + struct mii_bus *bus = priv->mii_bus; + u16 r1, r2, page; + u32 val; + + split_addr((u32) reg, &r1, &r2, &page); + ++ local_irq_save(flags); + mutex_lock(&bus->mdio_lock); + + bus->write(bus, 0x18, 0, page); +@@ -266,6 +268,7 @@ ar8xxx_read(struct ar8xxx_priv *priv, in + val = ar8xxx_mii_read32(priv, 0x10 | r2, r1); + + mutex_unlock(&bus->mdio_lock); ++ local_irq_restore(flags); + + return val; + } +@@ -273,11 +276,13 @@ ar8xxx_read(struct ar8xxx_priv *priv, in + void + ar8xxx_write(struct ar8xxx_priv *priv, int reg, u32 val) + { ++ unsigned long flags; + struct mii_bus *bus = priv->mii_bus; + u16 r1, r2, page; + + split_addr((u32) reg, &r1, &r2, &page); + ++ local_irq_save(flags); + mutex_lock(&bus->mdio_lock); + + bus->write(bus, 0x18, 0, page); +@@ -285,6 +290,7 @@ ar8xxx_write(struct ar8xxx_priv *priv, i + ar8xxx_mii_write32(priv, 0x10 | r2, r1, val); + + mutex_unlock(&bus->mdio_lock); ++ local_irq_restore(flags); + } + + u32