From nobody Sun Feb 8 16:12:13 2026 Received: from fllvem-ot04.ext.ti.com (fllvem-ot04.ext.ti.com [198.47.19.246]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C4C062676FC; Mon, 28 Apr 2025 12:05:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.19.246 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745841935; cv=none; b=WgxXxAS+w+l1ViYVW8OfjV83YYVRWXm7zQ2sE3xxSGb/SpgnbXprk0y4rRC6SiLem3L0OOMWf70CHwZFgHm6o/uutCTRqYv5u7tsNWV2lGEeaxDZgVwfjbu+QFYZ7+UKsG0bOgwSzn1LwcNZxTgWAT2DDW4vbpoCunlyeZ56FPo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745841935; c=relaxed/simple; bh=n6tPFBDBE/AoUx8+fT4xmiJ8DuWqqSs6nsXV22sbwkM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=UaVb98l9Xe8OT59a46AVD3Y0Bd6q863AjKpLo4uTb0HCzLmtZe+iZz7/9c5VLnX6/JItDVfKQ9sMIMyEVRgqP5Cywfprf7SS1lKDZDKFJxR5rqC8aOXvAkMrD04MosbFHNb7OdT0KbBDuYzP4X8P/nE5wcD+iQsvAsgolrOnv8Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=o30MvfUp; arc=none smtp.client-ip=198.47.19.246 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="o30MvfUp" Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllvem-ot04.ext.ti.com (8.15.2/8.15.2) with ESMTPS id 53SC58bi3393345 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 28 Apr 2025 07:05:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1745841908; bh=q+GVsZWnoS5nmRtEMNMV00DrIRXTh5+Y65jXU6cuPT0=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=o30MvfUpVOOWvdaeaNAsbGIIfBoFVS/pLK1CiYc5QzyJcmUtkv7gfGWDG8SUHpZDY 9RJhqMVbdevNacaVsdqoNvU5Y7gy3j45zG4ovjhbbQC+3q/r8NPswb/DlZD0vxGE8U cj+qUeHdtWQDGMDQToJqR5VkfXRr/aHsOnLu63M8= Received: from DFLE101.ent.ti.com (dfle101.ent.ti.com [10.64.6.22]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 53SC58WJ119440 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 28 Apr 2025 07:05:08 -0500 Received: from DFLE115.ent.ti.com (10.64.6.36) by DFLE101.ent.ti.com (10.64.6.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Mon, 28 Apr 2025 07:05:07 -0500 Received: from fllvsmtp8.itg.ti.com (10.64.41.158) by DFLE115.ent.ti.com (10.64.6.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Mon, 28 Apr 2025 07:05:07 -0500 Received: from lelv0854.itg.ti.com (lelv0854.itg.ti.com [10.181.64.140]) by fllvsmtp8.itg.ti.com (8.15.2/8.15.2) with ESMTP id 53SC57is098201; Mon, 28 Apr 2025 07:05:07 -0500 Received: from localhost (meghana-pc.dhcp.ti.com [10.24.69.13] (may be forged)) by lelv0854.itg.ti.com (8.14.7/8.14.7) with ESMTP id 53SC5687026332; Mon, 28 Apr 2025 07:05:07 -0500 From: Meghana Malladi To: , , , , , , , , , , CC: , , , , , Vignesh Raghavendra , Roger Quadros , Subject: [PATCH net 1/4] net: ti: icssg-prueth: Set XDP feature flags for ndev Date: Mon, 28 Apr 2025 17:34:56 +0530 Message-ID: <20250428120459.244525-2-m-malladi@ti.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250428120459.244525-1-m-malladi@ti.com> References: <20250428120459.244525-1-m-malladi@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea Content-Type: text/plain; charset="utf-8" xdp_features demonstrates what all XDP capabilities are supported on a given network device. The driver needs to set these xdp_features flag to let the network stack know what XDP features a given driver is supporting. These flags need to be set for a given ndev irrespective of any XDP program being loaded or not. Fixes: 62aa3246f462 ("net: ti: icssg-prueth: Add XDP support") Signed-off-by: Meghana Malladi --- drivers/net/ethernet/ti/icssg/icssg_prueth.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/ti/icssg/icssg_prueth.c b/drivers/net/eth= ernet/ti/icssg/icssg_prueth.c index 443f90fa6557..ee35fecf61e7 100644 --- a/drivers/net/ethernet/ti/icssg/icssg_prueth.c +++ b/drivers/net/ethernet/ti/icssg/icssg_prueth.c @@ -1109,11 +1109,6 @@ static int emac_xdp_xmit(struct net_device *dev, int= n, struct xdp_frame **frame static int emac_xdp_setup(struct prueth_emac *emac, struct netdev_bpf *bpf) { struct bpf_prog *prog =3D bpf->prog; - xdp_features_t val; - - val =3D NETDEV_XDP_ACT_BASIC | NETDEV_XDP_ACT_REDIRECT | - NETDEV_XDP_ACT_NDO_XMIT; - xdp_set_features_flag(emac->ndev, val); =20 if (!emac->xdpi.prog && !prog) return 0; @@ -1291,6 +1286,10 @@ static int prueth_netdev_init(struct prueth *prueth, ndev->hw_features =3D NETIF_F_SG; ndev->features =3D ndev->hw_features | NETIF_F_HW_VLAN_CTAG_FILTER; ndev->hw_features |=3D NETIF_PRUETH_HSR_OFFLOAD_FEATURES; + xdp_set_features_flag(ndev, + NETDEV_XDP_ACT_BASIC | + NETDEV_XDP_ACT_REDIRECT | + NETDEV_XDP_ACT_NDO_XMIT); =20 netif_napi_add(ndev, &emac->napi_rx, icssg_napi_rx_poll); hrtimer_setup(&emac->rx_hrtimer, &emac_rx_timer_callback, CLOCK_MONOTONIC, --=20 2.43.0 From nobody Sun Feb 8 16:12:13 2026 Received: from lelvem-ot02.ext.ti.com (lelvem-ot02.ext.ti.com [198.47.23.235]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DF9A226770A; Mon, 28 Apr 2025 12:05:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.23.235 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745841936; cv=none; b=rKT16GYjZGLpwnf3BjvgT7VDdRsq83SCRj7yyxkFvdU9wJ2yK7gh6cQicr6R4KwdFCyVt/+FZ+z0Z9ro7SYHJBB43RZ5XpLoyx+MOB3o4kZgOs8vmbqtjm3cVU/GSJ3S/B99YMaQTBceBr0Oc5cS0zNKr07KioYU4D7eyHv2H7k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745841936; c=relaxed/simple; bh=/T0BK1dAzfiLg7Xv0sUB5J7Ye6WraCyU1wtHgfAosrA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HC8rVxDQlepfmgmHTFLHkjpFCVLZiEOvmw7l/C4hBZMzVu1sIpxa8otffkB32CjXfKEO+A+Tut6o7F6LJzaf3tro9k9UizqHrZt7N5Axh9qIqcrQ5lYEqomrFDlFoDI47chyS2UiTDn6x1vXzH0caCo9d8joc7x0U+lvDkIuGt8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=rPAT4xJq; arc=none smtp.client-ip=198.47.23.235 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="rPAT4xJq" Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelvem-ot02.ext.ti.com (8.15.2/8.15.2) with ESMTPS id 53SC5BI83531559 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 28 Apr 2025 07:05:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1745841911; bh=uI+faJIxceA72XkODz4Mw86ruNESeEOpXr0xnsfEFzM=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=rPAT4xJqh+Yb/tPaodYVGiunw2ySTAXQfxfUMXG2GjYNMrmgfFPGYen0b8lL5f5GH gI+OdPgRmnVJvxEZPri39iy6iX1d9HWwGmZbzduZ1F0HrDUqBVzsVi8M6W9PSnSH6P LfJS3iUmMX8WnfXpSWWOCYecAF6cr/5zxgJynFQs= Received: from DFLE110.ent.ti.com (dfle110.ent.ti.com [10.64.6.31]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 53SC5BO1038306 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 28 Apr 2025 07:05:11 -0500 Received: from DFLE103.ent.ti.com (10.64.6.24) by DFLE110.ent.ti.com (10.64.6.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Mon, 28 Apr 2025 07:05:11 -0500 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DFLE103.ent.ti.com (10.64.6.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Mon, 28 Apr 2025 07:05:11 -0500 Received: from lelv0854.itg.ti.com (lelv0854.itg.ti.com [10.181.64.140]) by lelvsmtp5.itg.ti.com (8.15.2/8.15.2) with ESMTP id 53SC5Abt009667; Mon, 28 Apr 2025 07:05:10 -0500 Received: from localhost (meghana-pc.dhcp.ti.com [10.24.69.13] (may be forged)) by lelv0854.itg.ti.com (8.14.7/8.14.7) with ESMTP id 53SC59ag026337; Mon, 28 Apr 2025 07:05:10 -0500 From: Meghana Malladi To: , , , , , , , , , , CC: , , , , , Vignesh Raghavendra , Roger Quadros , Subject: [PATCH net 2/4] net: ti: icssg-prueth: Report BQL before sending XDP packets Date: Mon, 28 Apr 2025 17:34:57 +0530 Message-ID: <20250428120459.244525-3-m-malladi@ti.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250428120459.244525-1-m-malladi@ti.com> References: <20250428120459.244525-1-m-malladi@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea Content-Type: text/plain; charset="utf-8" When sending out any kind of traffic, it is essential that the driver keeps reporting BQL of the number of bytes that have been sent so that BQL can track the amount of data in the queue and prevents it from overflowing. If BQL is not reported, the driver may continue sending packets even when the queue is full, leading to packet loss, congestion and decreased network performance. Currently this is missing in emac_xmit_xdp_frame() and this patch fixes it. Fixes: 62aa3246f462 ("net: ti: icssg-prueth: Add XDP support") Signed-off-by: Meghana Malladi --- drivers/net/ethernet/ti/icssg/icssg_common.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/ti/icssg/icssg_common.c b/drivers/net/eth= ernet/ti/icssg/icssg_common.c index b4be76e13a2f..4f45f2b6b67f 100644 --- a/drivers/net/ethernet/ti/icssg/icssg_common.c +++ b/drivers/net/ethernet/ti/icssg/icssg_common.c @@ -187,7 +187,6 @@ int emac_tx_complete_packets(struct prueth_emac *emac, = int chn, xdp_return_frame(xdpf); break; default: - netdev_err(ndev, "tx_complete: invalid swdata type %d\n", swdata->type); prueth_xmit_free(tx_chn, desc_tx); ndev->stats.tx_dropped++; continue; @@ -567,6 +566,7 @@ u32 emac_xmit_xdp_frame(struct prueth_emac *emac, { struct cppi5_host_desc_t *first_desc; struct net_device *ndev =3D emac->ndev; + struct netdev_queue *netif_txq; struct prueth_tx_chn *tx_chn; dma_addr_t desc_dma, buf_dma; struct prueth_swdata *swdata; @@ -620,12 +620,17 @@ u32 emac_xmit_xdp_frame(struct prueth_emac *emac, swdata->data.xdpf =3D xdpf; } =20 + /* Report BQL before sending the packet */ + netif_txq =3D netdev_get_tx_queue(ndev, tx_chn->id); + netdev_tx_sent_queue(netif_txq, xdpf->len); + cppi5_hdesc_set_pktlen(first_desc, xdpf->len); desc_dma =3D k3_cppi_desc_pool_virt2dma(tx_chn->desc_pool, first_desc); =20 ret =3D k3_udma_glue_push_tx_chn(tx_chn->tx_chn, first_desc, desc_dma); if (ret) { netdev_err(ndev, "xdp tx: push failed: %d\n", ret); + netdev_tx_completed_queue(netif_txq, 1, xdpf->len); goto drop_free_descs; } =20 @@ -979,6 +984,7 @@ enum netdev_tx icssg_ndo_start_xmit(struct sk_buff *skb= , struct net_device *ndev ret =3D k3_udma_glue_push_tx_chn(tx_chn->tx_chn, first_desc, desc_dma); if (ret) { netdev_err(ndev, "tx: push failed: %d\n", ret); + netdev_tx_completed_queue(netif_txq, 1, pkt_len); goto drop_free_descs; } =20 --=20 2.43.0 From nobody Sun Feb 8 16:12:13 2026 Received: from fllvem-ot04.ext.ti.com (fllvem-ot04.ext.ti.com [198.47.19.246]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 84946267AF3; Mon, 28 Apr 2025 12:05:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.19.246 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745841937; cv=none; b=FJ4sMdSq2yFEK/YtHwXRnqvqGy7/u1iXt5ZkUNCZBahar6zb7PmdTlJisvBxpVK6OShqxqrExGOWXDZ+6dsohXhh9DYYxX2cqDyGcUUtJRBlBJijfcJyFBbjXp84Z1WDnMBqfLz9iqFd6t7LUY7dJ/YJoDee7vj7q09pOVc2HYI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745841937; c=relaxed/simple; bh=U3vCcy3+Zjk0V0Ir8A5u4CbF8+Bmq1aNjLLAmQ7P9Cs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=PZuKYqjqQrYhU2Z9P4mEePrnhnmhbud2No01oVjC4F1bGi7xSts7EC6rAPaJI27HVkEWPnn1unKxH++OCcJGFkBebY8BTxlHchu/2+/MZSAZiSl83Mi6mlFkaK6JPyvs0ddZKmxxi+S1FGLwRgpTb5Q27VeqS7FBGTK5mlBUfMY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=i4Y3GbTO; arc=none smtp.client-ip=198.47.19.246 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="i4Y3GbTO" Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllvem-ot04.ext.ti.com (8.15.2/8.15.2) with ESMTPS id 53SC5EVY3393353 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 28 Apr 2025 07:05:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1745841914; bh=JCpjZY3u/ZFHiA2q9iwsB5i+6p8X7uN+a9ZDPipJd7g=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=i4Y3GbTOdJqLfRgMBJnCUV4HvXYKB+vLXAPHLRz9dcbtumc527NhgNBB8it3K+jYj YKaIyVUP2Gn3Q9pc2rGXfD4Dw3XQ3b9RpqIC2WnL+YKZdV9NX541GKdT9v1Lt+UBUz qQXNaM0MvIBPfi3HHGjimuS3Pj9RBaFObguYVjFM= Received: from DLEE102.ent.ti.com (dlee102.ent.ti.com [157.170.170.32]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 53SC5E8K038320 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 28 Apr 2025 07:05:14 -0500 Received: from DLEE101.ent.ti.com (157.170.170.31) by DLEE102.ent.ti.com (157.170.170.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Mon, 28 Apr 2025 07:05:13 -0500 Received: from fllvsmtp8.itg.ti.com (10.64.41.158) by DLEE101.ent.ti.com (157.170.170.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Mon, 28 Apr 2025 07:05:14 -0500 Received: from lelv0854.itg.ti.com (lelv0854.itg.ti.com [10.181.64.140]) by fllvsmtp8.itg.ti.com (8.15.2/8.15.2) with ESMTP id 53SC5DF5098251; Mon, 28 Apr 2025 07:05:13 -0500 Received: from localhost (meghana-pc.dhcp.ti.com [10.24.69.13] (may be forged)) by lelv0854.itg.ti.com (8.14.7/8.14.7) with ESMTP id 53SC5CXv026354; Mon, 28 Apr 2025 07:05:13 -0500 From: Meghana Malladi To: , , , , , , , , , , CC: , , , , , Vignesh Raghavendra , Roger Quadros , Subject: [PATCH net 3/4] net: ti: icssg-prueth: Fix race condition for traffic from different network sockets Date: Mon, 28 Apr 2025 17:34:58 +0530 Message-ID: <20250428120459.244525-4-m-malladi@ti.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250428120459.244525-1-m-malladi@ti.com> References: <20250428120459.244525-1-m-malladi@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea Content-Type: text/plain; charset="utf-8" When dealing with transmitting traffic from different network sockets to a single Tx channel, freeing the DMA descriptors can lead to kernel panic with the following error: [ 394.602494] ------------[ cut here ]------------ [ 394.607134] kernel BUG at lib/genalloc.c:508! [ 394.611485] Internal error: Oops - BUG: 00000000f2000800 [#1] PREEMPT SMP logs: https://gist.github.com/MeghanaMalladiTI/ad1d1da3b6e966bc6962c105c0b1= d0b6 The above error was reproduced when sending XDP traffic from XSK socket along with network traffic from BSD socket. This causes a race condition leading to corrupted DMA descriptors. Fix this by adding spinlock protection while accessing the DMA descriptors of a Tx ring. Fixes: 62aa3246f462 ("net: ti: icssg-prueth: Add XDP support") Signed-off-by: Meghana Malladi --- drivers/net/ethernet/ti/icssg/icssg_common.c | 7 +++++++ drivers/net/ethernet/ti/icssg/icssg_prueth.h | 1 + 2 files changed, 8 insertions(+) diff --git a/drivers/net/ethernet/ti/icssg/icssg_common.c b/drivers/net/eth= ernet/ti/icssg/icssg_common.c index 4f45f2b6b67f..a120ff6fec8f 100644 --- a/drivers/net/ethernet/ti/icssg/icssg_common.c +++ b/drivers/net/ethernet/ti/icssg/icssg_common.c @@ -157,7 +157,9 @@ int emac_tx_complete_packets(struct prueth_emac *emac, = int chn, tx_chn =3D &emac->tx_chns[chn]; =20 while (true) { + spin_lock(&tx_chn->lock); res =3D k3_udma_glue_pop_tx_chn(tx_chn->tx_chn, &desc_dma); + spin_unlock(&tx_chn->lock); if (res =3D=3D -ENODATA) break; =20 @@ -325,6 +327,7 @@ int prueth_init_tx_chns(struct prueth_emac *emac) snprintf(tx_chn->name, sizeof(tx_chn->name), "tx%d-%d", slice, i); =20 + spin_lock_init(&tx_chn->lock); tx_chn->emac =3D emac; tx_chn->id =3D i; tx_chn->descs_num =3D PRUETH_MAX_TX_DESC; @@ -627,7 +630,9 @@ u32 emac_xmit_xdp_frame(struct prueth_emac *emac, cppi5_hdesc_set_pktlen(first_desc, xdpf->len); desc_dma =3D k3_cppi_desc_pool_virt2dma(tx_chn->desc_pool, first_desc); =20 + spin_lock_bh(&tx_chn->lock); ret =3D k3_udma_glue_push_tx_chn(tx_chn->tx_chn, first_desc, desc_dma); + spin_unlock_bh(&tx_chn->lock); if (ret) { netdev_err(ndev, "xdp tx: push failed: %d\n", ret); netdev_tx_completed_queue(netif_txq, 1, xdpf->len); @@ -981,7 +986,9 @@ enum netdev_tx icssg_ndo_start_xmit(struct sk_buff *skb= , struct net_device *ndev /* cppi5_desc_dump(first_desc, 64); */ =20 skb_tx_timestamp(skb); /* SW timestamp if SKBTX_IN_PROGRESS not set */ + spin_lock_bh(&tx_chn->lock); ret =3D k3_udma_glue_push_tx_chn(tx_chn->tx_chn, first_desc, desc_dma); + spin_unlock_bh(&tx_chn->lock); if (ret) { netdev_err(ndev, "tx: push failed: %d\n", ret); netdev_tx_completed_queue(netif_txq, 1, pkt_len); diff --git a/drivers/net/ethernet/ti/icssg/icssg_prueth.h b/drivers/net/eth= ernet/ti/icssg/icssg_prueth.h index b6be4aa57a61..4e5354c2866a 100644 --- a/drivers/net/ethernet/ti/icssg/icssg_prueth.h +++ b/drivers/net/ethernet/ti/icssg/icssg_prueth.h @@ -119,6 +119,7 @@ struct prueth_tx_chn { struct k3_cppi_desc_pool *desc_pool; struct k3_udma_glue_tx_channel *tx_chn; struct prueth_emac *emac; + spinlock_t lock; /* protect TX rings in multi-port mode */ u32 id; u32 descs_num; unsigned int irq; --=20 2.43.0 From nobody Sun Feb 8 16:12:13 2026 Received: from fllvem-ot04.ext.ti.com (fllvem-ot04.ext.ti.com [198.47.19.246]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A53A526A098; Mon, 28 Apr 2025 12:05:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.19.246 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745841940; cv=none; b=X8hrCfA9o/x5mm7MLMBBhuA2ntr0aH86o7j9E3zYwh1RU8/aoAx7Z36B3KP9YVFjTdmOjBzvJl/IBqAHoWUZZ/3w4pKAMUjuNSwdz+Xp1FNEUQ719yZdN6bB4KxiwuJkv3BdGLFI5ZlpenYXEUr8BlywsOPR/bLuOrj0X96lmdc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745841940; c=relaxed/simple; bh=8Gw7PZxetBy1RCwUT9rI04H1JYafJVt7sfEm7hf2k8I=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=biL18CVfpyVfzYn9Ki7zqXaEA2+xPSFJEhYEbAv0spUgykP0ZbzExwRi/jUOudM7zSawtzS5eK1zERzqlUiQyZfauY8Nx0bQvwrCAhwE7XPmOT89NpaNKTsgrtXoYTTA1RvmFtnAlXcp+ris+fKwDx4tIXY6VW2bPDXjNQ0dU9c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=DTiiK5OT; arc=none smtp.client-ip=198.47.19.246 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="DTiiK5OT" Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllvem-ot04.ext.ti.com (8.15.2/8.15.2) with ESMTPS id 53SC5IvP3393357 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 28 Apr 2025 07:05:18 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1745841918; bh=UOnsX2khC4QQb5DzauQ7MTn2WKff96OYmxGALdbK5CM=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=DTiiK5OTcuPZ7OW1xtZa+Ig0wRwTCT/hRNr354wkAlhVPgAP62gLS0hDK/8/nz1RW c/3LWpMjWGDhyAYtsZI6BQqEoJdSxJCqhEIoELehC21TSm6EAx3vHl2f712kebwXCB 4a1P8WSNmXQuuldUIpoQR7C/E/5SKsJcUgrTS1eY= Received: from DLEE110.ent.ti.com (dlee110.ent.ti.com [157.170.170.21]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 53SC5IpX038345 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 28 Apr 2025 07:05:18 -0500 Received: from DLEE101.ent.ti.com (157.170.170.31) by DLEE110.ent.ti.com (157.170.170.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Mon, 28 Apr 2025 07:05:17 -0500 Received: from fllvsmtp8.itg.ti.com (10.64.41.158) by DLEE101.ent.ti.com (157.170.170.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Mon, 28 Apr 2025 07:05:17 -0500 Received: from fllv0122.itg.ti.com (fllv0122.itg.ti.com [10.247.120.72]) by fllvsmtp8.itg.ti.com (8.15.2/8.15.2) with ESMTP id 53SC5H95098287; Mon, 28 Apr 2025 07:05:17 -0500 Received: from localhost (meghana-pc.dhcp.ti.com [10.24.69.13] (may be forged)) by fllv0122.itg.ti.com (8.14.7/8.14.7) with ESMTP id 53SC5G1B016903; Mon, 28 Apr 2025 07:05:17 -0500 From: Meghana Malladi To: , , , , , , , , , , CC: , , , , , Vignesh Raghavendra , Roger Quadros , Subject: [PATCH net 4/4] net: ti: icssg-prueth: Fix kernel panic during concurrent Tx queue access Date: Mon, 28 Apr 2025 17:34:59 +0530 Message-ID: <20250428120459.244525-5-m-malladi@ti.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250428120459.244525-1-m-malladi@ti.com> References: <20250428120459.244525-1-m-malladi@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea Content-Type: text/plain; charset="utf-8" Add __netif_tx_lock() to ensure that only one packet is being transmitted at a time to avoid race conditions in the netif_txq struct and prevent packet data corruption. Failing to do so causes kernel panic with the following error: [ 2184.746764] ------------[ cut here ]------------ [ 2184.751412] kernel BUG at lib/dynamic_queue_limits.c:99! [ 2184.756728] Internal error: Oops - BUG: 00000000f2000800 [#1] PREEMPT SMP logs: https://gist.github.com/MeghanaMalladiTI/9c7aa5fc3b7fb03f87c74aad4879= 56e9 The lock is acquired before calling emac_xmit_xdp_frame() and released afte= r the call returns. This ensures that the TX queue is protected from concurrent a= ccess during the transmission of XDP frames. Fixes: 62aa3246f462 ("net: ti: icssg-prueth: Add XDP support") Signed-off-by: Meghana Malladi --- drivers/net/ethernet/ti/icssg/icssg_common.c | 7 ++++++- drivers/net/ethernet/ti/icssg/icssg_prueth.c | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/ti/icssg/icssg_common.c b/drivers/net/eth= ernet/ti/icssg/icssg_common.c index a120ff6fec8f..e509b6ff81e7 100644 --- a/drivers/net/ethernet/ti/icssg/icssg_common.c +++ b/drivers/net/ethernet/ti/icssg/icssg_common.c @@ -660,6 +660,8 @@ static u32 emac_run_xdp(struct prueth_emac *emac, struc= t xdp_buff *xdp, struct page *page, u32 *len) { struct net_device *ndev =3D emac->ndev; + struct netdev_queue *netif_txq; + int cpu =3D smp_processor_id(); struct bpf_prog *xdp_prog; struct xdp_frame *xdpf; u32 pkt_len =3D *len; @@ -679,8 +681,11 @@ static u32 emac_run_xdp(struct prueth_emac *emac, stru= ct xdp_buff *xdp, goto drop; } =20 - q_idx =3D smp_processor_id() % emac->tx_ch_num; + q_idx =3D cpu % emac->tx_ch_num; + netif_txq =3D netdev_get_tx_queue(ndev, q_idx); + __netif_tx_lock(netif_txq, cpu); result =3D emac_xmit_xdp_frame(emac, xdpf, page, q_idx); + __netif_tx_unlock(netif_txq); if (result =3D=3D ICSSG_XDP_CONSUMED) { ndev->stats.tx_dropped++; goto drop; diff --git a/drivers/net/ethernet/ti/icssg/icssg_prueth.c b/drivers/net/eth= ernet/ti/icssg/icssg_prueth.c index ee35fecf61e7..b31060e7f698 100644 --- a/drivers/net/ethernet/ti/icssg/icssg_prueth.c +++ b/drivers/net/ethernet/ti/icssg/icssg_prueth.c @@ -1075,20 +1075,25 @@ static int emac_xdp_xmit(struct net_device *dev, in= t n, struct xdp_frame **frame { struct prueth_emac *emac =3D netdev_priv(dev); struct net_device *ndev =3D emac->ndev; + struct netdev_queue *netif_txq; + int cpu =3D smp_processor_id(); struct xdp_frame *xdpf; unsigned int q_idx; int nxmit =3D 0; u32 err; int i; =20 - q_idx =3D smp_processor_id() % emac->tx_ch_num; + q_idx =3D cpu % emac->tx_ch_num; + netif_txq =3D netdev_get_tx_queue(ndev, q_idx); =20 if (unlikely(flags & ~XDP_XMIT_FLAGS_MASK)) return -EINVAL; =20 for (i =3D 0; i < n; i++) { xdpf =3D frames[i]; + __netif_tx_lock(netif_txq, cpu); err =3D emac_xmit_xdp_frame(emac, xdpf, NULL, q_idx); + __netif_tx_unlock(netif_txq); if (err !=3D ICSSG_XDP_TX) { ndev->stats.tx_dropped++; break; --=20 2.43.0