Article View: linux.kernel.netdev
Article #5129[PATCH net-next v2 1/2] net: dsa: qca8k: serialize register access
From: Stanislaw Pal
Date: Mon, 19 Oct 2026 19:11
Date: Mon, 19 Oct 2026 19:11
57 lines
13234 bytes
13234 bytes
The regmap is created with .disable_locking, on the ground that
qca8k's read and write callbacks do their own locking. They only lock
the bus transaction, though: regmap formats the register and parses
the value in the map's shared work_buf, outside of them, so two
concurrent users can swap or corrupt each other's register and value.
Most register access runs under rtnl, but not all of it - phylink's
resolve work (mac_link_up/down) and the LED class callbacks do not -
and the next change adds a delayed work that reads the MIB. Let regmap
take its own lock; every user sleeps already, on the MDIO bus or on
the management frame round trip.
An autocast MIB read holds the MIB mutex while its register write
takes the management mutex, and qca8k_conduit_change() takes the two
the other way round. Both run under rtnl today; with a reader outside
rtnl that would be an ABBA deadlock. Take the MIB mutex first there
too.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Stanislaw Pal <kuncy7@gmail.com>
---
drivers/net/dsa/qca/qca8k-8xxx.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/net/dsa/qca/qca8k-8xxx.c b/drivers/net/dsa/qca/qca8k-8xxx.c
index 07227ae8b..9a8b9e34a 100644
--- a/drivers/net/dsa/qca/qca8k-8xxx.c
+++ b/drivers/net/dsa/qca/qca8k-8xxx.c
@@ -579,7 +579,6 @@ static const struct regmap_config qca8k_regmap_config = {
.write = qca8k_bulk_write,
.reg_update_bits = qca8k_regmap_update_bits,
.rd_table = &qca8k_readable_table,
- .disable_locking = true, /* Locking is handled by qca8k read/write */
.cache_type = REGCACHE_NONE, /* Explicitly disable CACHE */
.max_raw_read = 32, /* mgmt eth can read up to 8 registers at time */
/* ATU regs suffer from a bug where some data are not correctly
@@ -1782,13 +1781,16 @@ qca8k_conduit_change(struct dsa_switch *ds, const struct net_device *conduit,
if (dp->index != 0)
return;
- mutex_lock(&priv->mgmt_eth_data.mutex);
+ /* Same order as an autocast, which holds the MIB mutex while its
+ * register write takes the management one.
+ */
mutex_lock(&priv->mib_eth_data.mutex);
+ mutex_lock(&priv->mgmt_eth_data.mutex);
priv->mgmt_conduit = operational ? (struct net_device *)conduit : NULL;
- mutex_unlock(&priv->mib_eth_data.mutex);
mutex_unlock(&priv->mgmt_eth_data.mutex);
+ mutex_unlock(&priv->mib_eth_data.mutex);
}
static int qca8k_connect_tag_protocol(struct dsa_switch *ds,
--
2.43.0
Technical Details
Message-ID:
<20261019191137.307514-2-kuncy7@gmail.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-348790-linux-kernel-netdev=dewy.ruReferences:
<20261019191137.307514-1-kuncy7@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-348790-linux-kernel-netdev=dewy.ru
From: kuncy7@gmail.com (Stanislaw Pal)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net-next v2 1/2] net: dsa: qca8k: serialize register access
Date: Mon, 19 Oct 2026 21:11:36 +0200
Organization: Usenet Network
Message-ID: <20261019191137.307514-2-kuncy7@gmail.com>
References: <20261019191137.307514-1-kuncy7@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="3707527"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:WhnayZz3IQtSc9y0UT4gt3yUheo= sha256:Je1/gI3B0wrxwv0NiKPC/zPgpb/qy+Nc/vzqsxx/IJM=
sha1:eL+PQ98Oe/sP/szZg0iMCugk8YE= sha256:SPVSsdGzBTUUn7TO3exRqB2jKKerYJrAYRN6bQAsvRM=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
by mail.dewy.ru (Postfix) with ESMTP id CC559110B1E; Mon, 19 Oct 2026 23:35:04 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -2.048
X-Spam-Status: No, score=-2.048 tagged_above=-9999 required=6.31
tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
DKIM_VALID_AU=-0.1, FORGED_GMAIL_RCVD=1,
FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001,
HEADER_FROM_DIFFERENT_DOMAINS=0.25, MAILING_LIST_MULTI=-1,
RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001]
autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
header.d=gmail.com
X-Received: from mail.dewy.ru ([127.0.0.1])
by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id 0Tq2mxi-p58C;
Mon, 19 Oct 2026 23:35:02 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-348790-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
by mail.dewy.ru (Postfix) with ESMTPS id 654BB110AE6; Mon, 19 Oct 2026 23:34:52 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by sin.lore.kernel.org (Postfix) with ESMTP id 317983B3ED; Mon, 19 Oct 2026 19:12:13 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1792437130;
b=YUSTu400YBoKLvWu9dMdUPhZL/TF3nd9VvgZkQpzmVLX87FgoxAYVp0obvqrtEIIwZtM
9ziMrSIcvhlzo/KGoLjc0fFoA1ROunf1Lug5979ipzrzZ6+/YEDa+4ew7OkNj2wS15q/M
DLRHbVsBgiEb0XK5xEi9qmz979JKszz7rBqcaLBDH8H4xzqfWLgZxWXJhv4iGzU0sXcZa
1pPOzhODbf3wAB/rSTAG1Ek/aXK2ktv14sl7ScaPuXqwAlKhbY0nUWrnZfLv54NyGVdUR
XZxaxQJqOchgZmV8IGTQsYX3MEsHPL8hi8bFU8AqTLK6q8nbLcy+iKdyhX6m5Rbr6vw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1792437130;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Forwarded-Encrypted:X-Gm-Message-State:
X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:Date:Message-ID:
X-Mailer:In-Reply-To:References:X-Mailing-List:List-Id:List-Post:
List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence:
MIME-Version:Content-Transfer-Encoding;
bh=o1to95OGJg14CQlNiAHAtBtvI0GNBxi4w7KA/3PNH7A=;
b=P5yFQUeiA0yiGKFc9ZGQ6dFpyLnGAJ1SLmmd12HNOXPV5849Ic/2Fh6ZIrPI6PuSLY/d
eLRnGwILnLAh4ewGSGsPtQgyXrTxt8iZSlaRgb/6y2SNvrstStfma+keFHZUsY9y9CeQX
ca3r7eRSY5ZXmGebxk0LO+jH9ToY+oudiYiQGkZtfomA/rP1riGBLsozvGSbs+Sk4X3fD
qy9MgjWGqBwbkl/SA1PisXZRuMeF+G60UCg7ERKZ2SFQLalXinFrtEA6fQQj2SLJIn+qc
ZnC+Y97ppedeaTbsGJM+bzYKOvP6seHOzsJHfSc7xNIz6XZn85hiBR/S/iuc8jqteng==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=dBNC6SdT;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id 45AC9606A329;
Mon, 19 Oct 2026 19:12:10 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=dBNC6SdT
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.49
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1792437129;
b=QHs4w+/nu/YCvvyCZomQFqe5Oi5ykI5wCXT8gcLMDTnUQpLzgMvqAaf0qxUtjZ+1cUm7
6nPu3bjPYT8wZAzHJliKsyqzvZVlZJldJa+V45kU9qOfNgLjm88SFboBqQgz56NGVStkT
PWiKQb49JpDZk9FOYiM0DMHjN1FHlfG7PSWi/cyiLdE68/TorL0sHdLx3NWIERQEJcpKB
7k0eStQ0S0vEBegsP/P7U9RyS6uUs7dhhltb1BZvrOraNnFZAsIc4IHBMUQ379m4aRvlx
hrmCP2/4bBAat0PWlxaSxuhp8fcQhPBAStOXnQ02VLAmTdQ5/KVVND8ahD8Ay52jMiA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1792437129;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received:
From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References:
MIME-Version:Content-Transfer-Encoding;
bh=o1to95OGJg14CQlNiAHAtBtvI0GNBxi4w7KA/3PNH7A=;
b=fenner/JNd9im6NuE1PTiBrvegxsJrUGn8p/rMfPjE6O3AZt9jprQGs0sUxbf0sx0Vwn
/Mr6g5eXJdJLQ/zxNP6Rwonha9ka8d62pEbp7olriVf+WOVg7FZ+KckVvvAMyXOdEO2zt
4G7SZQT2eS+ct5+sN0gDU0le71qQr4+nCK6HTSi5fIZxXJDoIBlBy0nH0UoBvF7otf6nM
FjVQiy49zfXGcFRvdjUoutfWdQPW6PqUBkCiidbiMi9l0QlJoDMwow874HyYpw+6/Z1X4
/vckYdqn96X4eZAlml6UrNzWObBCAdcqlxlVQ6TOq+OhinPmTMSXbAPg9c6pPRonIGw==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=dBNC6SdT;
arc=none smtp.remote-ip=209.85.221.49
X-Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49])
(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id BD8F4606A31C
for <netdev@vger.kernel.org>; Mon, 19 Oct 2026 19:12:08 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org BD8F4606A31C
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-48c5358fc28so2078873f8f.0
for <netdev@vger.kernel.org>; Mon, 19 Oct 2026 12:12:08 -0700 (PDT)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20251104; t=1792437127; x=1793041927; darn=vger.kernel.org;
h=content-transfer-encoding:mime-version:references:in-reply-to
:message-id:date:subject:cc:to:from:from:to:cc:subject:date
:message-id:reply-to:content-type;
bh=o1to95OGJg14CQlNiAHAtBtvI0GNBxi4w7KA/3PNH7A=;
b=dBNC6SdTHt9dVPdShR6zs1QRfcsnZgjk1NZTAJ2lgzyWxWI8J5ea3pSdW8Edin+0eX
iIdB9dHO8CEdXQpAJedEznHeDr1+5XY3TVEWv0ot5PDwRbJPqcWMz/R+dfCHgIj8r2Po
Nj+Ce/WCgv5nObzV/TEEfGuMvzDIMC+EAR4VrZ3T3betd5XVCW8FWCKvBdjNxtKgx6zy
cqSdLq7zgGwTprzMmwtAhEb6EERLW7MU70N09wI7zPoz/DoIOgmMPk0NYVKmUrzKWhQq
M3ZM/l84Hq+zzqOlA2Gxxs29fSujBDv6xALuO7BcCij6iCC/vl987NfWpgc8MlG7VnC3
33NQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1792437127; x=1793041927;
h=content-transfer-encoding:mime-version:references:in-reply-to
:message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from
:to:cc:subject:date:message-id:reply-to:content-type;
bh=o1to95OGJg14CQlNiAHAtBtvI0GNBxi4w7KA/3PNH7A=;
b=ef4B5rFTi8WcG1mbPuMsgG12YiAZELVpeO9XF2wGMnJutO5ZsRpCD3xafZVDhvKFr0
Bl58bMv8LPhImHIAe7pqqAQIQZd5a+5RHzp4PjPaOyHaneIDP0RrdtTSyvxqfsDn6Azg
VmDr0s5Eq4l1PGTqVRKhC/nCNMzSFRiQ7xZoTcZ0pRm+ZxskmU6ULw4xKabm3gNI4WPK
HAHzQig5R8C02hBGSPMsTtuZB46v/ec1HKRclYZU+20mapx+FIivEC8WgZdu6x4reXYu
9wOj88HIcXYUfBWv1f3oEwOcO9BgnR19K4UPNwqFdisnzixTvOXlXHYiCE8UrTTcXYab
BaiA==
X-Forwarded-Encrypted: i=1; AKwUvBxsEWTgN/+dO8qiEGaKThOLKcqtXtNfOXZA+3xTshefxo21oaCpULw72vc9T9Kn8uq14CsEwPY=@vger.kernel.org
X-Gm-Message-State: AFq9FYIB/jkPWT8xT9KBUzoJFHQ+6lzX3fx6tdDlhEHFb3JGVm7/wZeI
hHhOTBLDjbsTyhFJDXnu0HU6QU0mFo9LXmH2cRdRyoswV4JnkTBdEAYx
X-Gm-Gg: AYBFou3kkSWNrXDGuUUf0HpsNo61ArpkZPfxWEChyNv2J2CDjL1mmjKTy6BeeTx6jiD
waY03abb8P8i2G08wDCzHPVdt2mTRUist5hOWTw+qYHR80iSaLiYmh5hchDy0bXJxsCBkvhbmQu
SYGb9jQS97j+JSDxBcLmcBK6hnIgmmV1thdChuDpInsA/ySyZlMrH77Dgvs3zQjQmJTpimkfy+r
bw7h2cgNaQIhnadvpxjHu9c+KtQccdyrv9K5IES6KfrwDYC+A91vu+/VyoAvpjEGdIbL84SlADG
uDdK11inI888gss5OQKNGyBUxlq7Ze/koamsTe8VNxFlIKBCGpzRiGP5mjMT6U9hLeQXfCl3Iyx
alxXWcKStVKEE7q+OkWM6Tq93Sphl/WPSoNS6tHtpYOuUN6CD6bgToWd/J1PsDDIQ35tkX7wl6A
8QpDplofzv30MT8BsJJhJ/e2QiITIHlNY/gL2Q8XBBR8PeSTebPJ8HMW5cDsVqHRxHcZXv55kkS
vshxYMgETPuyI6/yzC6
X-Received: by 2002:adf:e892:0:b0:48e:389:d2d5 with SMTP id ffacd0b85a97d-48e07fb744emr14210563f8f.51.1792437126993;
Mon, 19 Oct 2026 12:12:06 -0700 (PDT)
X-Received: from VivoBook-ASUS-X712UA-M712UA.lan ([2a00:f44:cd2:abb8:fed9:8342:c367:f022])
by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48e1d818c89sm804977f8f.32.2026.10.19.12.12.05
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Mon, 19 Oct 2026 12:12:06 -0700 (PDT)
X-Cc: "David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>,
netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
X-Mailer: git-send-email 2.43.0
X-In-Reply-To: <20261019191137.307514-1-kuncy7@gmail.com>
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list