drivers/net/ethernet/ti/am65-cpsw-nuss.c:1640:55: sparse: sparse: incorrect type in initializer (different address spaces)

From: kernel test robot
Date: Sat Dec 30 2023 - 23:19:51 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 453f5db0619e2ad64076aab16ff5a00e0f7c53a2
commit: 93a76530316a3d8cc2d82c3deca48424fee92100 net: ethernet: ti: introduce am65x/j721e gigabit eth subsystem driver
date: 3 years, 9 months ago
config: arm64-randconfig-r123-20231231 (https://download.01.org/0day-ci/archive/20231231/202312311235.NwNBzCd7-lkp@xxxxxxxxx/config)
compiler: aarch64-linux-gcc (GCC) 13.2.0
reproduce: (https://download.01.org/0day-ci/archive/20231231/202312311235.NwNBzCd7-lkp@xxxxxxxxx/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202312311235.NwNBzCd7-lkp@xxxxxxxxx/

sparse warnings: (new ones prefixed by >>)
>> drivers/net/ethernet/ti/am65-cpsw-nuss.c:1640:55: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected struct am65_cpsw_ndev_stats [noderef] __percpu *stats @@ got void *data @@
drivers/net/ethernet/ti/am65-cpsw-nuss.c:1640:55: sparse: expected struct am65_cpsw_ndev_stats [noderef] __percpu *stats
drivers/net/ethernet/ti/am65-cpsw-nuss.c:1640:55: sparse: got void *data
>> drivers/net/ethernet/ti/am65-cpsw-nuss.c:1692:49: sparse: sparse: incorrect type in argument 3 (different address spaces) @@ expected void *data @@ got struct am65_cpsw_ndev_stats [noderef] __percpu *stats @@
drivers/net/ethernet/ti/am65-cpsw-nuss.c:1692:49: sparse: expected void *data
drivers/net/ethernet/ti/am65-cpsw-nuss.c:1692:49: sparse: got struct am65_cpsw_ndev_stats [noderef] __percpu *stats

vim +1640 drivers/net/ethernet/ti/am65-cpsw-nuss.c

1637
1638 static void am65_cpsw_pcpu_stats_free(void *data)
1639 {
> 1640 struct am65_cpsw_ndev_stats __percpu *stats = data;
1641
1642 free_percpu(stats);
1643 }
1644
1645 static int am65_cpsw_nuss_init_ndev_2g(struct am65_cpsw_common *common)
1646 {
1647 struct am65_cpsw_ndev_priv *ndev_priv;
1648 struct device *dev = common->dev;
1649 struct am65_cpsw_port *port;
1650 int ret;
1651
1652 port = am65_common_get_port(common, 1);
1653
1654 /* alloc netdev */
1655 port->ndev = devm_alloc_etherdev_mqs(common->dev,
1656 sizeof(struct am65_cpsw_ndev_priv),
1657 AM65_CPSW_MAX_TX_QUEUES,
1658 AM65_CPSW_MAX_RX_QUEUES);
1659 if (!port->ndev) {
1660 dev_err(dev, "error allocating slave net_device %u\n",
1661 port->port_id);
1662 return -ENOMEM;
1663 }
1664
1665 ndev_priv = netdev_priv(port->ndev);
1666 ndev_priv->port = port;
1667 ndev_priv->msg_enable = AM65_CPSW_DEBUG;
1668 SET_NETDEV_DEV(port->ndev, dev);
1669
1670 ether_addr_copy(port->ndev->dev_addr, port->slave.mac_addr);
1671
1672 port->ndev->min_mtu = AM65_CPSW_MIN_PACKET_SIZE;
1673 port->ndev->max_mtu = AM65_CPSW_MAX_PACKET_SIZE;
1674 port->ndev->hw_features = NETIF_F_SG |
1675 NETIF_F_RXCSUM |
1676 NETIF_F_HW_CSUM;
1677 port->ndev->features = port->ndev->hw_features |
1678 NETIF_F_HW_VLAN_CTAG_FILTER;
1679 port->ndev->vlan_features |= NETIF_F_SG;
1680 port->ndev->netdev_ops = &am65_cpsw_nuss_netdev_ops_2g;
1681 port->ndev->ethtool_ops = &am65_cpsw_ethtool_ops_slave;
1682
1683 /* Disable TX checksum offload by default due to HW bug */
1684 if (common->pdata->quirks & AM65_CPSW_QUIRK_I2027_NO_TX_CSUM)
1685 port->ndev->features &= ~NETIF_F_HW_CSUM;
1686
1687 ndev_priv->stats = netdev_alloc_pcpu_stats(struct am65_cpsw_ndev_stats);
1688 if (!ndev_priv->stats)
1689 return -ENOMEM;
1690
1691 ret = devm_add_action_or_reset(dev, am65_cpsw_pcpu_stats_free,
> 1692 ndev_priv->stats);
1693 if (ret) {
1694 dev_err(dev, "failed to add percpu stat free action %d", ret);
1695 return ret;
1696 }
1697
1698 netif_napi_add(port->ndev, &common->napi_rx,
1699 am65_cpsw_nuss_rx_poll, NAPI_POLL_WEIGHT);
1700
1701 common->pf_p0_rx_ptype_rrobin = false;
1702
1703 return ret;
1704 }
1705

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki