From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F356DC61DD3 for ; Mon, 31 Aug 2026 09:59:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Fwbh1BauoCb6UctKkvdsUX/G9J4v4lYocRurXVp5kIo=; b=0qNPHvVa/kbd9kf8OpKCrOclMj TM5aCCyToAkBaKJXtogQabtE5e7TsWUPhwQFbDkHsybSWiW9Ao8pj4sVXJMfLBF2/mLzP96o8n7mC FQ5/NuZ3SKTx07gWq69YEJz5YdNbuSzGlTyg5lZByZ7mNusqUh+nAKQwrhnaPQ5Zjmcz8sgb/1cH+ iKB3dQ/7gCCsdEaZaFYpxI1x0uVTJ4Dk63QoXRz0rdGt8u83MIy1/bTX4vYxPUUm+lj3DZNqDU9t4 X9IbrUKiAUftIvbjnu2tnzUM8PHyGDNE8vuDPAb9R0uzwqirTQx5uMhmuo+XrGXwUe4GHBXS1RDzI iDnbHU8g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1x0yns-000000094b5-1Kn2; Mon, 31 Aug 2026 09:59:48 +0000 Received: from smtpout-02.galae.net ([185.246.84.56]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1x0ynp-000000094Zr-1cCL for linux-arm-kernel@lists.infradead.org; Mon, 31 Aug 2026 09:59:46 +0000 Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id DE3621A18EF; Mon, 31 Aug 2026 09:59:43 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id B02CA60231; Mon, 31 Aug 2026 09:59:43 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 327E311C78AE0; Mon, 31 Aug 2026 11:59:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1788170382; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:content-language:in-reply-to:references; bh=Fwbh1BauoCb6UctKkvdsUX/G9J4v4lYocRurXVp5kIo=; b=2owBSYIG8csu/XHdXVOEV3A3VNcK+7wcll8Mn/J3qLuURYicsk2zVyfIdpaDDjPcUmV6JN XEV6SQkh+YOhvhnVVLwz6rZB347mvWz7kKAQrwb2puAmuNa+GvgCwUp57lKT0UhERTMP92 HdAYtmbA84jgj6CESrFcLtyq9FQ8CsfdnGHj2ghfOY41tRVNz2szpUknTC0X0v8TnlQESl U66NgVjUhYeZSm9NuE4VqfOL6MNoLET5xM6c72N4GFGxmVkJqfB9VQRVPO8UsD5/WpPZFf /haFarr/vJ4WlW18fIK2celBXPq1UWXg5mI2wp0iuorBYjXfS8/X60+W827X6g== Message-ID: Date: Mon, 31 Aug 2026 11:59:36 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net v2] net: stmmac: hold runtime PM reference in setup_tc To: Lorenzo Bianconi , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Alexandre Torgue , Jose Abreu Cc: netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org References: <20260827-stmmac-setup-tc-enable-pm-v2-1-a9b8a5948f41@oss.qualcomm.com> Content-Language: en-US From: Maxime Chevallier In-Reply-To: <20260827-stmmac-setup-tc-enable-pm-v2-1-a9b8a5948f41@oss.qualcomm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Last-TLS-Session-Version: TLSv1.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260831_025945_576475_0A7935A7 X-CRM114-Status: GOOD ( 22.06 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi, On 8/27/26 09:12, Lorenzo Bianconi wrote: > The qdisc offload callbacks invoked by stmmac_setup_tc() program > MTL/MAC registers, but they can be reached while the interface is down, > when stmmac_release() has dropped the runtime PM usage counter and the > device may be suspended with its clocks gated. Accessing the registers > in that state can trigger a bus error. > > Hold a runtime PM reference while configuring the register-touching > qdisc offloads (mqprio, cbs and taprio) so the device is active, and its > clocks enabled, whenever the MTL/MAC registers are programmed. > > The TC block callback stmmac_setup_tc_block_cb() programs the MTL/MAC > registers as well, but it runs asynchronously from stmmac_setup_tc(), > outside the runtime PM reference held there. Hold a runtime PM reference > for the whole stmmac_setup_tc_block_cb() call as well, covering the > cls_u32/cls_flower setup and the queue enable/disable accesses. > > No reference is held for the TC_SETUP_BLOCK bookkeeping itself, the > TC_QUERY_CAPS query or the tc-etf path, since none of them touch the > registers synchronously. In particular the block bind/unbind must reach > flow_block_cb_setup_simple() even when the device is suspended, so the > driver never leaves a stale flow_block_cb on its block list. > > Fixes: 1f705bc61aee ("net: stmmac: Add support for CBS QDISC") > Fixes: 4dbbe8dde848 ("net: stmmac: Add support for U32 TC filter using Flexible RX Parser") > Signed-off-by: Lorenzo Bianconi Reviewed-by: Maxime Chevallier Maxime > --- > Changes in v2: > - Return -EOPNOTSUPP in stmmac_setup_tc_block_cb() for unsupported TC > blocks. > - Link to v1: https://lore.kernel.org/r/20260824-stmmac-setup-tc-enable-pm-v1-1-45172d241a4b@oss.qualcomm.com > --- > drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 35 ++++++++++++++++++++--- > 1 file changed, 31 insertions(+), 4 deletions(-) > > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > index efa35cfecc4f..90753d5af6d6 100644 > --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > @@ -6393,9 +6393,13 @@ static int stmmac_setup_tc_block_cb(enum tc_setup_type type, void *type_data, > void *cb_priv) > { > struct stmmac_priv *priv = cb_priv; > - int ret = -EOPNOTSUPP; > + int ret; > > if (!tc_cls_can_offload_and_chain0(priv->dev, type_data)) > + return -EOPNOTSUPP; > + > + ret = pm_runtime_resume_and_get(priv->device); > + if (ret < 0) > return ret; > > __stmmac_disable_all_queues(priv); > @@ -6408,10 +6412,13 @@ static int stmmac_setup_tc_block_cb(enum tc_setup_type type, void *type_data, > ret = stmmac_tc_setup_cls(priv, priv, type_data); > break; > default: > + ret = -EOPNOTSUPP; > break; > } > > stmmac_enable_all_queues(priv); > + pm_runtime_put(priv->device); > + > return ret; > } > > @@ -6421,26 +6428,46 @@ static int stmmac_setup_tc(struct net_device *ndev, enum tc_setup_type type, > void *type_data) > { > struct stmmac_priv *priv = netdev_priv(ndev); > + int ret; > > switch (type) { > case TC_QUERY_CAPS: > return stmmac_tc_query_caps(priv, priv, type_data); > case TC_SETUP_QDISC_MQPRIO: > - return stmmac_tc_setup_mqprio(priv, priv, type_data); > + ret = pm_runtime_resume_and_get(priv->device); > + if (ret < 0) > + return ret; > + > + ret = stmmac_tc_setup_mqprio(priv, priv, type_data); > + break; > case TC_SETUP_BLOCK: > return flow_block_cb_setup_simple(type_data, > &stmmac_block_cb_list, > stmmac_setup_tc_block_cb, > priv, priv, true); > case TC_SETUP_QDISC_CBS: > - return stmmac_tc_setup_cbs(priv, priv, type_data); > + ret = pm_runtime_resume_and_get(priv->device); > + if (ret < 0) > + return ret; > + > + ret = stmmac_tc_setup_cbs(priv, priv, type_data); > + break; > case TC_SETUP_QDISC_TAPRIO: > - return stmmac_tc_setup_taprio(priv, priv, type_data); > + ret = pm_runtime_resume_and_get(priv->device); > + if (ret < 0) > + return ret; > + > + ret = stmmac_tc_setup_taprio(priv, priv, type_data); > + break; > case TC_SETUP_QDISC_ETF: > return stmmac_tc_setup_etf(priv, priv, type_data); > default: > return -EOPNOTSUPP; > } > + > + pm_runtime_put(priv->device); > + > + return ret; > } > > static u16 stmmac_select_queue(struct net_device *dev, struct sk_buff *skb, > > --- > base-commit: f967455fb2a5a2079b9eb5823e9ccf359174bf9f > change-id: 20260824-stmmac-setup-tc-enable-pm-149aa563d797 > > Best regards,