[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220818182948.931712-2-saproj@gmail.com>
Date: Thu, 18 Aug 2022 21:29:48 +0300
From: Sergei Antonov <saproj@...il.com>
To: netdev@...r.kernel.org
Cc: Andrew Lunn <andrew@...n.ch>, Jakub Kicinski <kuba@...nel.org>,
Vladimir Oltean <olteanv@...il.com>,
Sergei Antonov <saproj@...il.com>
Subject: [PATCH 2/2] net: moxa: prevent double-mapping of DMA areas
Fix the warning poping up after bringing the link down, then up:
ip link set dev eth0 down
ip link set dev eth0 up
WARNING: CPU: 0 PID: 55 at kernel/dma/debug.c:570 add_dma_entry+0x204/0x2ec
DMA-API: moxart-ethernet 92000000.mac: cacheline tracking EEXIST, overlapping mappings aren't supported
CPU: 0 PID: 55 Comm: ip Not tainted 5.19.0+ #57
Hardware name: Generic DT based system
unwind_backtrace from show_stack+0x10/0x14
show_stack from dump_stack_lvl+0x34/0x44
dump_stack_lvl from __warn+0xbc/0x1f0
__warn from warn_slowpath_fmt+0x94/0xc8
warn_slowpath_fmt from add_dma_entry+0x204/0x2ec
add_dma_entry from dma_map_page_attrs+0x110/0x328
dma_map_page_attrs from moxart_mac_open+0x134/0x320
moxart_mac_open from __dev_open+0x11c/0x1ec
__dev_open from __dev_change_flags+0x194/0x22c
__dev_change_flags from dev_change_flags+0x14/0x44
dev_change_flags from devinet_ioctl+0x6d4/0x93c
devinet_ioctl from inet_ioctl+0x1ac/0x25c
Unmap RX memory areas in moxart_mac_stop(), so that moxart_mac_open()
will map them anew instead of double-mapping. To avoid code duplication,
create a new function moxart_mac_unmap_rx(). Nullify unmapped pointers to
prevent double-unmapping (ex: moxart_mac_stop(), then moxart_remove()).
Fixes: 6c821bd9edc9 ("net: Add MOXA ART SoCs ethernet driver")
Signed-off-by: Sergei Antonov <saproj@...il.com>
---
drivers/net/ethernet/moxa/moxart_ether.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/moxa/moxart_ether.c b/drivers/net/ethernet/moxa/moxart_ether.c
index edd1dab2ec43..22d0bf4a21e7 100644
--- a/drivers/net/ethernet/moxa/moxart_ether.c
+++ b/drivers/net/ethernet/moxa/moxart_ether.c
@@ -71,15 +71,23 @@ static int moxart_set_mac_address(struct net_device *ndev, void *addr)
return 0;
}
-static void moxart_mac_free_memory(struct net_device *ndev)
+static void moxart_mac_unmap_rx(struct moxart_mac_priv_t *priv)
{
- struct moxart_mac_priv_t *priv = netdev_priv(ndev);
int i;
for (i = 0; i < RX_DESC_NUM; i++)
- if (priv->rx_mapping[i])
+ if (priv->rx_mapping[i]) {
dma_unmap_single(&priv->pdev->dev, priv->rx_mapping[i],
priv->rx_buf_size, DMA_FROM_DEVICE);
+ priv->rx_mapping[i] = 0;
+ }
+}
+
+static void moxart_mac_free_memory(struct net_device *ndev)
+{
+ struct moxart_mac_priv_t *priv = netdev_priv(ndev);
+
+ moxart_mac_unmap_rx(priv);
if (priv->tx_desc_base)
dma_free_coherent(&priv->pdev->dev,
@@ -205,6 +213,7 @@ static int moxart_mac_stop(struct net_device *ndev)
/* disable all functions */
writel(0, priv->base + REG_MAC_CTRL);
+ moxart_mac_unmap_rx(priv);
return 0;
}
--
2.32.0
Powered by blists - more mailing lists