🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #16556

Re: [PATCH v7 net-next 4/9] net: dsa: netc: tie setup resources and reset to DSA setup/teardown

#16556
From: netdev-bot+sashiko
Date: Sun, 15 Nov 2026 07:24
111 lines
11578 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 0

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] The patch makes the first netc_setup() skip the reset
  (priv->configured == false) on the grounds that "the probe path…

--

net: dsa: netc: tie setup resources and reset to DSA setup/teardown

This patch adds netc_switch_reset(), which netc_setup() calls first so
each DSA setup starts from a clean hardware state. The first setup skips
the reset and relies on the probe-time FLR. The patch also turns the
setup-path devm_ allocations into explicit alloc/free calls, released in
netc_teardown() and on the error paths.

> diff --git a/drivers/net/dsa/netc/netc_main.c b/drivers/net/dsa/netc/netc_main.c
> index 77077352c1a57..c291123f53170 100644
> --- a/drivers/net/dsa/netc/netc_main.c
> +++ b/drivers/net/dsa/netc/netc_main.c

[ ... ]

> +static int netc_switch_reset(struct netc_switch *priv)
> +{
> +	struct pci_dev *pdev = priv->pdev;
> +	int err;
> +
> +	if (!priv->configured) {
> +		/* The hardware will be configured after netc_switch_reset()
> +		 * is called, so set priv->configured to true.
> +		 */
> +		priv->configured = true;
> +		return 0;
> +	}

[Severity: Medium]
Can the first netc_setup() start on stale hardware tables if the FLR in
probe failed?

The commit message says:

    The probe path already performs a FLR in netc_switch_pci_init(), so
    the first setup will skip the reset because the priv->configured flag
    is not set.

But netc_switch_pci_init() ignores the pcie_flr() return value:

drivers/net/dsa/netc/netc_main.c:netc_switch_pci_init() {
    ...
	pcie_flr(pdev);
	err = pcim_enable_device(pdev);
    ...
}

pcie_flr() can fail. It returns -ENOTTY if config space is not
accessible or if pci_dev_wait() times out. It can also fail through
pci_dev_reset_iommu_prepare() for an ATS-capable device behind an IOMMU.

Suppose that happens after an unbind/rebind:

netc_switch_probe()
  netc_switch_pci_init()
    pcie_flr()            <- fails, error ignored
  dsa_register_switch()
    netc_setup()
      netc_switch_reset() <- returns 0 early, !priv->configured

The FDB, VLAN filter, IPFT, BPT and ETT entries from the previous binding
would then stay in hardware. netc_setup() builds empty software state on
top of them, and the driver has no record of those entries to remove.

Later setups treat an FLR failure as fatal, so a failed first FLR is
handled differently. Should the probe path check the pcie_flr() result
and fail probe? Alternatively, priv->configured could be set only after
a successful FLR, so that the first setup retries the reset.

> +
> +	/* Block user space config access and other PCI resets, which take
> +	 * pci_cfg_access_lock() via pci_dev_lock(), during the FLR.
> +	 */
> +	pci_cfg_access_lock(pdev);
> +	err = pci_save_state(pdev);
> +	if (err)
> +		goto unlock_cfg_access;
> +
> +	err = pcie_flr(pdev);
> +	if (err)
> +		dev_err(priv->dev, "FLR failed: %pe\n", ERR_PTR(err));
> +
> +	pci_restore_state(pdev);
> +
> +unlock_cfg_access:
> +	pci_cfg_access_unlock(pdev);
> +
> +	return err;
>  }

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261111062753.1397582-1-wei.fang%40oss.nxp.com
Technical Details
Message-ID: <179472746345.2199510.13684304240938201686@kernel.org>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder3.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-363587-linux-kernel-netdev=dewy.ru
References: <20261111062753.1397582-5-wei.fang@oss.nxp.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder3.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-363587-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH v7 net-next 4/9] net: dsa: netc: tie setup resources and reset to DSA setup/teardown
Date: Sun, 15 Nov 2026 07:24:23 +0000
Organization: Usenet Network
Message-ID: <179472746345.2199510.13684304240938201686@kernel.org>
References: <20261111062753.1397582-5-wei.fang@oss.nxp.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network; logging-data="1747230"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:9SznXxRLE9dDBJhwuP9UKnSiDbc= sha256:sCunsmH8wq+IZK6Xmn5bJ/ud+G4BXvHYa4WSAs2FZBI= sha1:XRLCcyEskx8sCdppdSMaC+pf9gw= sha256:/HGxLH7lUV8BPDlofrfvbYXodkNmFH4PomNalHS6RXc=
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 B960311495A; Sun, 15 Nov 2026 10:25:00 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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=kernel.org
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 QcjH-ymFrdmW; Sun, 15 Nov 2026 10:24:56 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-363587-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 385CB1143C3; Sun, 15 Nov 2026 10:24:48 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 20FA53AE99; Sun, 15 Nov 2026 07:24:41 +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=1794727471; b=I2CbYJhw2RhuoVT2PiYWGQRgadzKfSg8bQqwP0paDvqneQqW/CICU5vqEu6UTM1O7O5H 3lnTg+zet/aoqKFeTj2slHrKITG9JI6X6P03+vFi7Wu3xl+Yfyos2eDhV3FCA7nZCwvOS XNONFZ/IMNPnutPr2mJgljouKCnBGrW4/a5mwpDrBA41YqaaiIBh8imRReR8aEAORz6YH FanWs/kTzsaspMSlbtmwz6MJI1JeuaYLMH912tmz9HQiIDJ3KfRCOonGZIXBUOtRdNvMW 0FYG2l9a04lbA/St0ZHULegxQRm1zEN3BgLzouxAUOzTgnc00k7pZJSMNnwsjYFu/aA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794727471; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=AidHs0Awemb2NZ24itVBVZKYL6ptkEfvldQHKQBgGl0=; b=1nWIhiiCVcv7mohXF04noZJhmiPj9rLaxHyelWcAiBeJjC5gVusz7rOeTRhsBwWVt1Xh /aI5O84wQhWq1pwmpPTO1FUpw4tfRCVP2hZrAo6WVYN5YvDl0AbqXGYzaOr8VyVJiIx5+ /MXIXoWIK36nmh3RQRsEkpRjJt+komPUZ4bMuSEZJZlU/HROnaehNLp8KNvmae4tGt1Na Q6XY6DS6EtYEodcBXtGh5+u69eSp1f3v0FtFPibi+2ANronArCpuXPWHeuWOBLJ2snwkK zAMiYAG8BY9qStG1BnFLU78yCpTDlonwXdaf79qiVr0RlLy0vRUYcEqUipaVqFdDhFg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=J9D0afPn; 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 35919606A8BC; Sun, 15 Nov 2026 07:24:31 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=J9D0afPn
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794727465; b=J8Vjils+VPrOfO67hYs8AH4jdPKrWIPnNp8MP94CMbPqVGz9RS9iEwI0ULsEXND3EWPZ Zn2nS3GCvKMuyYX7uRmvkC4Ao6rR0ub09w0LoLFb01tTCrlBg5f9zmzTkAPR4GA5RuaK7 rp3ZOxwCzYFVU3BQdTcUXMd3hvgb2vLpCALX+Gl9ldkkZyqIakCDXvMsd4shurAk3Mot4 0yOHIw684JLNnWfff89l7xQsz44GTqb6qtcsQwI39m+nXHskNS9TyxLEka0Q0D4Ou/O8S 8Jn5IQf/rD2ugLwma3lo/R3GpWx2SRjkl0tb9QOUeUdzUmm+Qve/+n8QumsyVH6CZyg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794727465; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=AidHs0Awemb2NZ24itVBVZKYL6ptkEfvldQHKQBgGl0=; b=LcIq85woFkwLiMGsCxgIEF+PAOBwYg01+p0QipVFwac+7/q6HMDKNl4VCDlpYY0oA9Ur fMarRQOrqv2h561n1p/Tq0td6ZkNECensrFTjMhe+ImUUMGeKFg9eU84ogK9OIg7oZEf/ oMXwVC6ox1f6K9C7Gcig3orOn6l3qY7Lcac5ftQMN90L61hrsdZS00GJ3HBMZZc1kd37V 1mBxavSvx580Tj0B0EDDWRAvjVjHvL9gvqpgeQUeFbKbT4ti2EMFmKT+K4e6NJC1pc3ld 3hsRG5wPp0qsHfG+1Xtizyi9Xzt4CP71IEt4ldDNFeMAmeLZoQPEH8b9Lgt90ZqJ29g==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=J9D0afPn; arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 51C71606A327; Sun, 15 Nov 2026 07:24:25 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id E50281F000C4; Sun, 15 Nov 2026 07:24:23 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794727464; bh=AidHs0Awemb2NZ24itVBVZKYL6ptkEfvldQHKQBgGl0=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=J9D0afPnqD/0sfW+WAvE5yqR5xx4q5F1P40g3fB8SgXIXt03kybektbsmLTAz7ka8 BJYYsvbzT8Gdg0OhCrqbtEy+XcVDpZ4a35cEv0HPLPFVVlWZ2kK2ZYzkgU6PBTirG1 jdCVoZEWD0S9FFoVdgkaVOATKn2i8CeA3IzhKCKpMnzmgcnYKup3qc6NCqFxO158/Q bOMhJB9UPKjOH9abL0QMfx5HzjwGol/FqCgZ6VhfPZ4ncbzwmrJcNpR2zNlZsoGppH kNItHofx6sfPkth1MoRpH8Jm8k98VOgu0i6oqaAtlej0fdJtp+KlOy7Q++TodO8fYd flN96cmOMKOQg==
X-Cc: xiaoning.wang@nxp.com, andrew@lunn.ch, olteanv@gmail.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, richardcochran@gmail.com, linusw@kernel.org, linux@armlinux.org.uk, wei.fang@nxp.com, imx@lists.linux.dev, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org
X-In-Reply-To: <20261111062753.1397582-5-wei.fang@oss.nxp.com>
X-sashiko-severity: Medium
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