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 516BAC79FAD for ; Wed, 9 Sep 2026 13:01:11 +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:CC:To:In-Reply-To:References :Message-ID:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=F24hYjTw68k8tzyIqz4pOT3jXUpUmN91fwoS/YeMT8Y=; b=wQSvt2U7k5Zk4aj/SMdVBkkvZJ B05z7nkZUGX/pQhgu0EYOdAy9hvSgLjUvbKy/wxP09Kmdfnp9AmwYc8KMw+3iPDcABn38/z/CA+MI v5SLkg0dvfcApKc1OT2LfN9yRTYRreB4eq6ZWZUyWn3lalWuvBo+OsRJf0aoYZKVGPAiA8xyxW21f aT/fy+68vvlV/aj/1S/b1xjk3ilem/ntOK+6D9WwCHzCYBCqqxmt0VBBlpbCZYeHkn+4i1e8FkTPv MRHd/HDyn+mbeOeTtclpFjA8bO/7Pzg08t1AsMUCYknuC48Ia1tXenl3RiXpGlk96muoqlph+mmgB y3LgxAIA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1x4HvD-0000000Bj7o-3coK; Wed, 09 Sep 2026 13:01:03 +0000 Received: from esa.microchip.iphmx.com ([68.232.153.233]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1x4HvA-0000000Bj4J-2ct5 for linux-arm-kernel@lists.infradead.org; Wed, 09 Sep 2026 13:01:01 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1788958860; x=1820494860; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=//1Sej3ygsAUOeV8Xbw9m53S52nHYA3SXR8Urfm05bw=; b=XWJcvLaXERQQFKVXxGmwIIdlzelVJa1Q4pN4KqkFTiQI8z4CNY+GDIHN aSe+dcKs9t8L0CqjYRbSYy+XzAh/FqP1z6qRjm4weq3AUPNityO6H8Nkt DJlNmVtr+tXxl7Zzkq+BumOekPbxtDUIOXbM0QDRpHKSZLdVsB9bg40m1 tgKmFfbfzbpEG07o2GH5ReHCKB0aFP8xVvYjAjOcsiyuphPiC3nXCjR0d 3dN1bt0lHaYS+V5JBob0QAKr97X9ACLgjNRyQAK3I+pwvEQ5ryGa4bi0M CE6HLpovqLjpU0r8rC3dGapYDlrmb0NTFdb2ObU0XkMzc3LEK+zmZ3Yci Q==; X-CSE-ConnectionGUID: 7eRe6HgDTF2R+8/Z6zeXFg== X-CSE-MsgGUID: 7LG8u9CqT2SlIST+25QDLA== X-IronPort-AV: E=Sophos;i="6.25,270,1779174000"; d="scan'208";a="294759147" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa5.microchip.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Sep 2026 06:01:00 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.87.72) by chn-vm-ex3.mchp-main.com (10.10.87.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.2562.45; Wed, 9 Sep 2026 06:00:59 -0700 Received: from DEN-DL-M70577.microsemi.net (10.10.85.11) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.2507.58 via Frontend Transport; Wed, 9 Sep 2026 06:00:55 -0700 From: Daniel Machon Date: Wed, 9 Sep 2026 15:00:11 +0200 Subject: [PATCH net-next v6 09/14] net: lan966x: add shutdown callback to stop FDMA on reboot MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-ID: <20260909-lan966x-pci-fdma-v6-9-6f48dab9d671@microchip.com> References: <20260909-lan966x-pci-fdma-v6-0-6f48dab9d671@microchip.com> In-Reply-To: <20260909-lan966x-pci-fdma-v6-0-6f48dab9d671@microchip.com> To: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Horatiu Vultur , Steen Hegelund , , "Alexei Starovoitov" , Daniel Borkmann , "Jesper Dangaard Brouer" , John Fastabend , Stanislav Fomichev , Herve Codina , Arnd Bergmann , Greg Kroah-Hartman , Mohsin Bashir CC: Richard Cochran , , , , X-Mailer: b4 0.14.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260909_060100_708337_58AB4C1F X-CRM114-Status: GOOD ( 21.64 ) 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 When lan966x is used as a PCIe endpoint, the FDMA engine runs on the card and survives a host reboot. Without a shutdown callback, channels stay active and interrupt sources stay armed across the reset, causing the shared PCIe INTx to assert before the driver has re-probed. Add a shutdown callback, shared by the platform and PCI paths, that disables NAPI and stops the netdev TX queues, then disables the RX and TX channels, and finally masks the interrupt sources that share the PCIe INTx: FDMA (FDMA_INTR_ENA and FDMA_INTR_DB_ENA) and the analyzer (ANA_ANAINTR), which lan966x_init() arms unconditionally. Masking is only required on this path: on reboot the kernel calls device_shutdown(), so shutdown() is the only callback that runs. On unbind, fdma_deinit() disables both channels and waits for them to go idle before lan966x_cleanup_ports() releases the FDMA interrupt handler, so the engine cannot assert the shared line once the handler is gone. FDMA_INTR_ENA persists on the card across a warm reboot, so also restore the full enable in lan966x_fdma_rx_start() to re-arm interrupts after a previous shutdown(). rx_start() runs after both the RX and TX rings are allocated, so the same single-site re-arm works for both the platform and PCIe backends. Tested-by: Herve Codina Signed-off-by: Daniel Machon --- .../net/ethernet/microchip/lan966x/lan966x_fdma.c | 19 ++++++++++++++++ .../net/ethernet/microchip/lan966x/lan966x_main.c | 26 ++++++++++++++++++++++ .../net/ethernet/microchip/lan966x/lan966x_main.h | 1 + .../net/ethernet/microchip/lan966x/lan966x_regs.h | 15 +++++++++++++ 4 files changed, 61 insertions(+) diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c b/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c index 2695bc41e52a..5793a83268fc 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c @@ -146,6 +146,10 @@ void lan966x_fdma_rx_start(struct lan966x_rx *rx) struct fdma *fdma = &rx->fdma; u32 mask; + lan_wr(FDMA_INTR_ENA_INTR_PORT_ENA_SET(GENMASK(1, 0)) | + FDMA_INTR_ENA_INTR_CH_ENA_SET(GENMASK(7, 0)), + lan966x, FDMA_INTR_ENA); + lan_wr(FDMA_CH_CFG_CH_DCB_DB_CNT_SET(fdma->n_dbs) | FDMA_CH_CFG_CH_INTR_DB_EOF_ONLY_SET(1) | FDMA_CH_CFG_CH_INJ_PORT_SET(0) | @@ -325,6 +329,21 @@ static void lan966x_fdma_stop_netdev(struct lan966x *lan966x) } } +/* Drain in-flight xmit callers and stop all TX queues on every port. */ +void lan966x_fdma_tx_disable_netdev(struct lan966x *lan966x) +{ + struct lan966x_port *port; + int i; + + for (i = 0; i < lan966x->num_phys_ports; ++i) { + port = lan966x->ports[i]; + if (!port) + continue; + + netif_tx_disable(port->dev); + } +} + static void lan966x_fdma_tx_clear_buf(struct lan966x *lan966x, int weight) { struct lan966x_tx *tx = &lan966x->tx; diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c index 11094a381ec2..d6ce1e3e373f 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c @@ -1324,9 +1324,35 @@ static void lan966x_remove(struct platform_device *pdev) debugfs_remove_recursive(lan966x->debugfs_root); } +static void lan966x_shutdown(struct platform_device *pdev) +{ + struct lan966x *lan966x = platform_get_drvdata(pdev); + + if (!lan966x->fdma) + return; + + /* The reload paths disable this NAPI under rtnl; serialize with them. */ + rtnl_lock(); + + if (lan966x->fdma_ndev) + napi_disable(&lan966x->napi); + + lan966x_fdma_tx_disable_netdev(lan966x); + + lan966x_fdma_rx_disable(&lan966x->rx); + lan966x_fdma_tx_disable(&lan966x->tx); + + lan_wr(0, lan966x, FDMA_INTR_ENA); + lan_wr(0, lan966x, FDMA_INTR_DB_ENA); + lan_wr(0, lan966x, ANA_ANAINTR); + + rtnl_unlock(); +} + static struct platform_driver lan966x_driver = { .probe = lan966x_probe, .remove = lan966x_remove, + .shutdown = lan966x_shutdown, .driver = { .name = "lan966x-switch", .of_match_table = lan966x_match, diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_main.h b/drivers/net/ethernet/microchip/lan966x/lan966x_main.h index aab5e53ed059..b7e3ce4f0355 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_main.h +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_main.h @@ -586,6 +586,7 @@ void lan966x_fdma_rx_reload(struct lan966x_rx *rx); void lan966x_fdma_tx_start(struct lan966x_tx *tx); void lan966x_fdma_tx_disable(struct lan966x_tx *tx); void lan966x_fdma_wakeup_netdev(struct lan966x *lan966x); +void lan966x_fdma_tx_disable_netdev(struct lan966x *lan966x); int lan966x_fdma_get_max_frame(struct lan966x *lan966x); int lan966x_qsys_sw_status(struct lan966x *lan966x); diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_regs.h b/drivers/net/ethernet/microchip/lan966x/lan966x_regs.h index 4b553927d2e0..aba0d36ae6b5 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_regs.h +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_regs.h @@ -1039,6 +1039,21 @@ enum lan966x_target { /* FDMA:FDMA:FDMA_INTR_ERR */ #define FDMA_INTR_ERR __REG(TARGET_FDMA, 0, 1, 8, 0, 1, 428, 400, 0, 1, 4) +/* FDMA:FDMA:FDMA_INTR_ENA */ +#define FDMA_INTR_ENA __REG(TARGET_FDMA, 0, 1, 8, 0, 1, 428, 404, 0, 1, 4) + +#define FDMA_INTR_ENA_INTR_PORT_ENA GENMASK(9, 8) +#define FDMA_INTR_ENA_INTR_PORT_ENA_SET(x)\ + FIELD_PREP(FDMA_INTR_ENA_INTR_PORT_ENA, x) +#define FDMA_INTR_ENA_INTR_PORT_ENA_GET(x)\ + FIELD_GET(FDMA_INTR_ENA_INTR_PORT_ENA, x) + +#define FDMA_INTR_ENA_INTR_CH_ENA GENMASK(7, 0) +#define FDMA_INTR_ENA_INTR_CH_ENA_SET(x)\ + FIELD_PREP(FDMA_INTR_ENA_INTR_CH_ENA, x) +#define FDMA_INTR_ENA_INTR_CH_ENA_GET(x)\ + FIELD_GET(FDMA_INTR_ENA_INTR_CH_ENA, x) + /* FDMA:FDMA:FDMA_ERRORS */ #define FDMA_ERRORS __REG(TARGET_FDMA, 0, 1, 8, 0, 1, 428, 412, 0, 1, 4) -- 2.34.1