Message ID | 20220617203312.3799646-19-sean.anderson@seco.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | net: dpaa: Convert to phylink | expand |
Hi Sean, I love your patch! Perhaps something to improve: [auto build test WARNING on net-next/master] url: https://github.com/intel-lab-lkp/linux/commits/Sean-Anderson/net-dpaa-Convert-to-phylink/20220618-044003 base: https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 4875d94c69d5a4836c4225b51429d277c297aae8 config: arc-allyesconfig (https://download.01.org/0day-ci/archive/20220618/202206180959.mgYg6khw-lkp@intel.com/config) compiler: arceb-elf-gcc (GCC) 11.3.0 reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/intel-lab-lkp/linux/commit/91ca730be8451e814e919382364039413db7e5bb git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Sean-Anderson/net-dpaa-Convert-to-phylink/20220618-044003 git checkout 91ca730be8451e814e919382364039413db7e5bb # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.3.0 make.cross W=1 O=build_dir ARCH=arc SHELL=/bin/bash drivers/net/ethernet/freescale/fman/ If you fix the issue, kindly add following tag where applicable Reported-by: kernel test robot <lkp@intel.com> All warnings (new ones prefixed by >>): drivers/net/ethernet/freescale/fman/mac.c: In function 'mac_exception': drivers/net/ethernet/freescale/fman/mac.c:48:34: warning: variable 'priv' set but not used [-Wunused-but-set-variable] 48 | struct mac_priv_s *priv; | ^~~~ drivers/net/ethernet/freescale/fman/mac.c: In function 'mac_probe': >> drivers/net/ethernet/freescale/fman/mac.c:387:30: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] 387 | mac_dev->vaddr_end = (void *)res->end; | ^ vim +387 drivers/net/ethernet/freescale/fman/mac.c 297 298 static int mac_probe(struct platform_device *_of_dev) 299 { 300 int err, i, nph; 301 int (*init)(struct mac_device *mac_dev, struct device_node *mac_node); 302 struct device *dev; 303 struct device_node *mac_node, *dev_node; 304 struct mac_device *mac_dev; 305 struct platform_device *of_dev; 306 struct resource *res; 307 struct mac_priv_s *priv; 308 u32 val; 309 u8 fman_id; 310 phy_interface_t phy_if; 311 312 dev = &_of_dev->dev; 313 mac_node = dev->of_node; 314 init = of_device_get_match_data(dev); 315 316 mac_dev = devm_kzalloc(dev, sizeof(*mac_dev), GFP_KERNEL); 317 if (!mac_dev) { 318 err = -ENOMEM; 319 goto _return; 320 } 321 priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); 322 if (!priv) { 323 err = -ENOMEM; 324 goto _return; 325 } 326 327 /* Save private information */ 328 mac_dev->priv = priv; 329 mac_dev->dev = dev; 330 331 INIT_LIST_HEAD(&priv->mc_addr_list); 332 333 /* Get the FM node */ 334 dev_node = of_get_parent(mac_node); 335 if (!dev_node) { 336 dev_err(dev, "of_get_parent(%pOF) failed\n", 337 mac_node); 338 err = -EINVAL; 339 goto _return_of_node_put; 340 } 341 342 of_dev = of_find_device_by_node(dev_node); 343 if (!of_dev) { 344 dev_err(dev, "of_find_device_by_node(%pOF) failed\n", dev_node); 345 err = -EINVAL; 346 goto _return_of_node_put; 347 } 348 349 /* Get the FMan cell-index */ 350 err = of_property_read_u32(dev_node, "cell-index", &val); 351 if (err) { 352 dev_err(dev, "failed to read cell-index for %pOF\n", dev_node); 353 err = -EINVAL; 354 goto _return_of_node_put; 355 } 356 /* cell-index 0 => FMan id 1 */ 357 fman_id = (u8)(val + 1); 358 359 priv->fman = fman_bind(&of_dev->dev); 360 if (!priv->fman) { 361 dev_err(dev, "fman_bind(%pOF) failed\n", dev_node); 362 err = -ENODEV; 363 goto _return_of_node_put; 364 } 365 366 of_node_put(dev_node); 367 368 /* Get the address of the memory mapped registers */ 369 res = platform_get_mem_or_io(_of_dev, 0); 370 if (!res) { 371 dev_err(dev, "could not get registers\n"); 372 return -EINVAL; 373 } 374 375 err = devm_request_resource(dev, fman_get_mem_region(priv->fman), res); 376 if (err) { 377 dev_err_probe(dev, err, "could not request resource\n"); 378 goto _return_of_node_put; 379 } 380 381 mac_dev->vaddr = devm_ioremap(dev, res->start, resource_size(res)); 382 if (!mac_dev->vaddr) { 383 dev_err(dev, "devm_ioremap() failed\n"); 384 err = -EIO; 385 goto _return_of_node_put; 386 } > 387 mac_dev->vaddr_end = (void *)res->end; 388 389 if (!of_device_is_available(mac_node)) { 390 err = -ENODEV; 391 goto _return_of_node_put; 392 } 393 394 /* Get the cell-index */ 395 err = of_property_read_u32(mac_node, "cell-index", &val); 396 if (err) { 397 dev_err(dev, "failed to read cell-index for %pOF\n", mac_node); 398 err = -EINVAL; 399 goto _return_of_node_put; 400 } 401 priv->cell_index = (u8)val; 402 403 /* Get the MAC address */ 404 err = of_get_mac_address(mac_node, mac_dev->addr); 405 if (err) 406 dev_warn(dev, "of_get_mac_address(%pOF) failed\n", mac_node); 407 408 /* Get the port handles */ 409 nph = of_count_phandle_with_args(mac_node, "fsl,fman-ports", NULL); 410 if (unlikely(nph < 0)) { 411 dev_err(dev, "of_count_phandle_with_args(%pOF, fsl,fman-ports) failed\n", 412 mac_node); 413 err = nph; 414 goto _return_of_node_put; 415 } 416 417 if (nph != ARRAY_SIZE(mac_dev->port)) { 418 dev_err(dev, "Not supported number of fman-ports handles of mac node %pOF from device tree\n", 419 mac_node); 420 err = -EINVAL; 421 goto _return_of_node_put; 422 } 423 424 for (i = 0; i < ARRAY_SIZE(mac_dev->port); i++) { 425 /* Find the port node */ 426 dev_node = of_parse_phandle(mac_node, "fsl,fman-ports", i); 427 if (!dev_node) { 428 dev_err(dev, "of_parse_phandle(%pOF, fsl,fman-ports) failed\n", 429 mac_node); 430 err = -EINVAL; 431 goto _return_of_node_put; 432 } 433 434 of_dev = of_find_device_by_node(dev_node); 435 if (!of_dev) { 436 dev_err(dev, "of_find_device_by_node(%pOF) failed\n", 437 dev_node); 438 err = -EINVAL; 439 goto _return_of_node_put; 440 } 441 442 mac_dev->port[i] = fman_port_bind(&of_dev->dev); 443 if (!mac_dev->port[i]) { 444 dev_err(dev, "dev_get_drvdata(%pOF) failed\n", 445 dev_node); 446 err = -EINVAL; 447 goto _return_of_node_put; 448 } 449 of_node_put(dev_node); 450 } 451 452 /* Get the PHY connection type */ 453 err = of_get_phy_mode(mac_node, &phy_if); 454 if (err) { 455 dev_warn(dev, 456 "of_get_phy_mode() for %pOF failed. Defaulting to SGMII\n", 457 mac_node); 458 phy_if = PHY_INTERFACE_MODE_SGMII; 459 } 460 mac_dev->phy_if = phy_if; 461 462 priv->speed = phy2speed[mac_dev->phy_if]; 463 priv->max_speed = priv->speed; 464 mac_dev->if_support = DTSEC_SUPPORTED; 465 /* We don't support half-duplex in SGMII mode */ 466 if (mac_dev->phy_if == PHY_INTERFACE_MODE_SGMII) 467 mac_dev->if_support &= ~(SUPPORTED_10baseT_Half | 468 SUPPORTED_100baseT_Half); 469 470 /* Gigabit support (no half-duplex) */ 471 if (priv->max_speed == 1000) 472 mac_dev->if_support |= SUPPORTED_1000baseT_Full; 473 474 /* The 10G interface only supports one mode */ 475 if (mac_dev->phy_if == PHY_INTERFACE_MODE_XGMII) 476 mac_dev->if_support = SUPPORTED_10000baseT_Full; 477 478 /* Get the rest of the PHY information */ 479 mac_dev->phy_node = of_parse_phandle(mac_node, "phy-handle", 0); 480 481 err = init(mac_dev, mac_node); 482 if (err < 0) { 483 dev_err(dev, "mac_dev->init() = %d\n", err); 484 of_node_put(mac_dev->phy_node); 485 goto _return_of_node_put; 486 } 487 488 /* pause frame autonegotiation enabled */ 489 mac_dev->autoneg_pause = true; 490 491 /* By intializing the values to false, force FMD to enable PAUSE frames 492 * on RX and TX 493 */ 494 mac_dev->rx_pause_req = true; 495 mac_dev->tx_pause_req = true; 496 mac_dev->rx_pause_active = false; 497 mac_dev->tx_pause_active = false; 498 err = fman_set_mac_active_pause(mac_dev, true, true); 499 if (err < 0) 500 dev_err(dev, "fman_set_mac_active_pause() = %d\n", err); 501 502 if (!is_zero_ether_addr(mac_dev->addr)) 503 dev_info(dev, "FMan MAC address: %pM\n", mac_dev->addr); 504 505 priv->eth_dev = dpaa_eth_add_device(fman_id, mac_dev); 506 if (IS_ERR(priv->eth_dev)) { 507 dev_err(dev, "failed to add Ethernet platform device for MAC %d\n", 508 priv->cell_index); 509 priv->eth_dev = NULL; 510 } 511 512 goto _return; 513 514 _return_of_node_put: 515 of_node_put(dev_node); 516 _return: 517 return err; 518 } 519
diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c index a548598b2e2d..d443d53c4504 100644 --- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c @@ -218,8 +218,8 @@ static int dpaa_netdev_init(struct net_device *net_dev, net_dev->netdev_ops = dpaa_ops; mac_addr = priv->mac_dev->addr; - net_dev->mem_start = priv->mac_dev->res->start; - net_dev->mem_end = priv->mac_dev->res->end; + net_dev->mem_start = (unsigned long)priv->mac_dev->vaddr; + net_dev->mem_end = (unsigned long)priv->mac_dev->vaddr_end; net_dev->min_mtu = ETH_MIN_MTU; net_dev->max_mtu = dpaa_get_max_mtu(); diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth_sysfs.c b/drivers/net/ethernet/freescale/dpaa/dpaa_eth_sysfs.c index 4fee74c024bd..258eb6c8f4c0 100644 --- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth_sysfs.c +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth_sysfs.c @@ -18,7 +18,7 @@ static ssize_t dpaa_eth_show_addr(struct device *dev, if (mac_dev) return sprintf(buf, "%llx", - (unsigned long long)mac_dev->res->start); + (unsigned long long)mac_dev->vaddr); else return sprintf(buf, "none"); } diff --git a/drivers/net/ethernet/freescale/fman/mac.c b/drivers/net/ethernet/freescale/fman/mac.c index e33d8b87f70f..e8ef307bd1ca 100644 --- a/drivers/net/ethernet/freescale/fman/mac.c +++ b/drivers/net/ethernet/freescale/fman/mac.c @@ -28,7 +28,6 @@ MODULE_LICENSE("Dual BSD/GPL"); MODULE_DESCRIPTION("FSL FMan MAC API based driver"); struct mac_priv_s { - void __iomem *vaddr; u8 cell_index; struct fman *fman; /* List of multicast addresses */ @@ -67,12 +66,7 @@ int set_fman_mac_params(struct mac_device *mac_dev, { struct mac_priv_s *priv = mac_dev->priv; - params->base_addr = (typeof(params->base_addr)) - devm_ioremap(mac_dev->dev, mac_dev->res->start, - resource_size(mac_dev->res)); - if (!params->base_addr) - return -ENOMEM; - + params->base_addr = mac_dev->vaddr; memcpy(¶ms->addr, mac_dev->addr, sizeof(mac_dev->addr)); params->max_speed = priv->max_speed; params->phy_if = mac_dev->phy_if; @@ -309,7 +303,7 @@ static int mac_probe(struct platform_device *_of_dev) struct device_node *mac_node, *dev_node; struct mac_device *mac_dev; struct platform_device *of_dev; - struct resource res; + struct resource *res; struct mac_priv_s *priv; u32 val; u8 fman_id; @@ -372,30 +366,25 @@ static int mac_probe(struct platform_device *_of_dev) of_node_put(dev_node); /* Get the address of the memory mapped registers */ - err = of_address_to_resource(mac_node, 0, &res); - if (err < 0) { - dev_err(dev, "of_address_to_resource(%pOF) = %d\n", - mac_node, err); - goto _return_of_node_put; + res = platform_get_mem_or_io(_of_dev, 0); + if (!res) { + dev_err(dev, "could not get registers\n"); + return -EINVAL; } - mac_dev->res = __devm_request_region(dev, - fman_get_mem_region(priv->fman), - res.start, resource_size(&res), - "mac"); - if (!mac_dev->res) { - dev_err(dev, "__devm_request_mem_region(mac) failed\n"); - err = -EBUSY; + err = devm_request_resource(dev, fman_get_mem_region(priv->fman), res); + if (err) { + dev_err_probe(dev, err, "could not request resource\n"); goto _return_of_node_put; } - priv->vaddr = devm_ioremap(dev, mac_dev->res->start, - resource_size(mac_dev->res)); - if (!priv->vaddr) { + mac_dev->vaddr = devm_ioremap(dev, res->start, resource_size(res)); + if (!mac_dev->vaddr) { dev_err(dev, "devm_ioremap() failed\n"); err = -EIO; goto _return_of_node_put; } + mac_dev->vaddr_end = (void *)res->end; if (!of_device_is_available(mac_node)) { err = -ENODEV; diff --git a/drivers/net/ethernet/freescale/fman/mac.h b/drivers/net/ethernet/freescale/fman/mac.h index da410a7d00c9..7aa71b05bd3e 100644 --- a/drivers/net/ethernet/freescale/fman/mac.h +++ b/drivers/net/ethernet/freescale/fman/mac.h @@ -19,8 +19,9 @@ struct fman_mac; struct mac_priv_s; struct mac_device { + void __iomem *vaddr; + void __iomem *vaddr_end; struct device *dev; - struct resource *res; u8 addr[ETH_ALEN]; struct fman_port *port[2]; u32 if_support;
We don't need to remap the base address from the resource twice (once in mac_probe() and again in set_fman_mac_params()). We still need the resource to get the end address, but we can use a single function call to get both at once. While we're at it, use platform_get_mem_or_io and devm_request_resource to map the resource. I think this is the more "correct" way to do things here, since we use the pdev resource, instead of creating a new one. It's still a bit tricy, since we need to ensure that the resource is a child of the fman region when it gets requested. Signed-off-by: Sean Anderson <sean.anderson@seco.com> --- .../net/ethernet/freescale/dpaa/dpaa_eth.c | 4 +-- .../ethernet/freescale/dpaa/dpaa_eth_sysfs.c | 2 +- drivers/net/ethernet/freescale/fman/mac.c | 35 +++++++------------ drivers/net/ethernet/freescale/fman/mac.h | 3 +- 4 files changed, 17 insertions(+), 27 deletions(-)