From dcde0815d94656a673874cb5d21b577c1473c9ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Georg=20M=C3=BCller?= Date: Tue, 25 Apr 2023 15:34:34 +0200 Subject: [PATCH 1/3] use dma_set_mask_and_coherent() instead of pci_set_* functions pci_set_dma_mask() and pci_set_consistent_dma_mask() were removed with kernel 5.18. dma_set_mask_and_coherent() exists since kernel 3.13. --- modules/exanic/exanic-main.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/modules/exanic/exanic-main.c b/modules/exanic/exanic-main.c index a004f8a..299c92e 100644 --- a/modules/exanic/exanic-main.c +++ b/modules/exanic/exanic-main.c @@ -1156,17 +1156,10 @@ static int exanic_probe(struct pci_dev *pdev, dev_info(dev, "DMA address width: %u bits.\n", exanic->dma_addr_bits); } - err = pci_set_dma_mask(pdev, DMA_BIT_MASK(exanic->dma_addr_bits)); + err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(exanic->dma_addr_bits)); if (err) { - dev_err(dev, "pci_set_dma_mask failed: %d\n", err); - goto err_dma_mask; - } - - err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(exanic->dma_addr_bits)); - if (err) - { - dev_err(dev, "pci_set_consistent_dma_mask failed: %d\n", err); + dev_err(dev, "dma_set_mask_and_coherent failed: %d\n", err); goto err_dma_mask; } From 5e0c16e909c88a6da73bf0e85b7055f133fd0d23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Georg=20M=C3=BCller?= Date: Tue, 25 Apr 2023 15:34:40 +0200 Subject: [PATCH 2/3] support linux 6.1+ The last parameter (weight) of netif_napi_add() was removed with kernel 6.1 with linux commit b48b89f9c1. The weight of 64 is now the default. --- modules/exanic/exanic-netdev.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/exanic/exanic-netdev.c b/modules/exanic/exanic-netdev.c index a2c86ee..6e8b107 100644 --- a/modules/exanic/exanic-netdev.c +++ b/modules/exanic/exanic-netdev.c @@ -1932,7 +1932,11 @@ int exanic_netdev_alloc(struct exanic *exanic, unsigned port, spin_lock_init(&priv->tx_lock); SET_NETDEV_DEV(ndev, exanic_dev(exanic)); +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) netif_napi_add(ndev, &priv->napi, exanic_netdev_poll, 64); +#else + netif_napi_add(ndev, &priv->napi, exanic_netdev_poll); +#endif ndev->ethtool_ops = &exanic_ethtool_ops; SET_ETHTOOL_OPS_EXT(ndev, &exanic_ethtool_ops_ext); ndev->netdev_ops = &exanic_ndos; From 38e80f92226d330964d5f059353baae10bda2fec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Georg=20M=C3=BCller?= Date: Tue, 25 Apr 2023 15:34:48 +0200 Subject: [PATCH 3/3] don't write directly to netdev->dev_addr netdev->dev_addr is const now. This fixes compilation warning and an OOPS with linux 5.17+. --- modules/exanic/exanic-netdev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/exanic/exanic-netdev.c b/modules/exanic/exanic-netdev.c index 6e8b107..ea8699d 100644 --- a/modules/exanic/exanic-netdev.c +++ b/modules/exanic/exanic-netdev.c @@ -1064,7 +1064,7 @@ static int exanic_netdev_set_mac_addr(struct net_device *ndev, void *p) if (!err) err = exanic_get_mac_addr_regs(priv->exanic, priv->port, mac_addr); if (!err) - memcpy(ndev->dev_addr, mac_addr, ETH_ALEN); + eth_hw_addr_set(ndev, mac_addr); mutex_unlock(mutex); @@ -1943,7 +1943,7 @@ int exanic_netdev_alloc(struct exanic *exanic, unsigned port, err = exanic_get_mac_addr_regs(exanic, port, mac_addr); if (!err) - memcpy(ndev->dev_addr, mac_addr, ETH_ALEN); + eth_hw_addr_set(ndev, mac_addr); memcpy(ndev->perm_addr, exanic->port[port].orig_mac_addr, ETH_ALEN);