diff mbox series

r8169: Avoid duplicate sysfs entry creation error

Message ID 20210622125206.1437-1-andre.przywara@arm.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series r8169: Avoid duplicate sysfs entry creation error | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Guessed tree name to be net-next
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit fail Errors and warnings before: 0 this patch: 7
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 9 lines checked
netdev/build_allmodconfig_warn fail Errors and warnings before: 0 this patch: 7
netdev/header_inline success Link

Commit Message

Andre Przywara June 22, 2021, 12:52 p.m. UTC
From: Sayanta Pattanayak <sayanta.pattanayak@arm.com>

When registering the MDIO bus for a r8169 device, we use the PCI B/D/F
specifier as a (seemingly) unique device identifier.
However the very same BDF number can be used on another PCI segment,
which makes the driver fail probing:

[ 27.544136] r8169 0002:07:00.0: enabling device (0000 -> 0003)
[ 27.559734] sysfs: cannot create duplicate filename '/class/mdio_bus/r8169-700'
....…
[ 27.684858] libphy: mii_bus r8169-700 failed to register
[ 27.695602] r8169: probe of 0002:07:00.0 failed with error -22

Add the segment number to the device name to make it more unique.

This fixes operation on an ARM N1SDP board, where two boards might be
connected together to form an SMP system, and all on-board devices show
up twice, just on different PCI segments.

Signed-off-by: Sayanta Pattanayak <sayanta.pattanayak@arm.com>
[Andre: expand commit message]
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
---
 drivers/net/ethernet/realtek/r8169_main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

kernel test robot June 23, 2021, 2:14 p.m. UTC | #1
Hi Andre,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v5.13-rc7 next-20210622]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Andre-Przywara/r8169-Avoid-duplicate-sysfs-entry-creation-error/20210622-205319
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git a96bfed64c8986d6404e553f18203cae1f5ac7e6
config: x86_64-rhel-8.3-kselftests (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.3-341-g8af24329-dirty
        # https://github.com/0day-ci/linux/commit/d832a81ab997133a25b71a3066a51708edf39054
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Andre-Przywara/r8169-Avoid-duplicate-sysfs-entry-creation-error/20210622-205319
        git checkout d832a81ab997133a25b71a3066a51708edf39054
        # save the attached .config to linux build tree
        make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' W=1 ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   drivers/net/ethernet/realtek/r8169_main.c: In function 'r8169_mdio_register':
>> drivers/net/ethernet/realtek/r8169_main.c:5090:13: error: 'struct pci_bus' has no member named 'domain_nr'
    5090 |    pdev->bus->domain_nr, pci_dev_id(pdev));
         |             ^~
--
     452 | void run_dax(struct dax_device *dax_dev)
         |      ^~~~~~~
   drivers/dax/super.c:227: warning: Function parameter or member 'list' not described in 'dax_device'
   drivers/dax/super.c:227: warning: Function parameter or member 'ops' not described in 'dax_device'
   drivers/gpu/drm/drm_file.c:789:6: warning: no previous prototype for 'drm_send_event_helper' [-Wmissing-prototypes]
     789 | void drm_send_event_helper(struct drm_device *dev,
         |      ^~~~~~~~~~~~~~~~~~~~~
   drivers/acpi/dock.c:388: warning: Function parameter or member 'ds' not described in 'handle_eject_request'
   drivers/acpi/dock.c:388: warning: Function parameter or member 'event' not described in 'handle_eject_request'
   lib/iov_iter.c:752: warning: Function parameter or member 'i' not described in '_copy_mc_to_iter'
   lib/iov_iter.c:752: warning: Excess function parameter 'iter' description in '_copy_mc_to_iter'
   lib/iov_iter.c:888: warning: Function parameter or member 'i' not described in '_copy_from_iter_flushcache'
   lib/iov_iter.c:888: warning: Excess function parameter 'iter' description in '_copy_from_iter_flushcache'
   fs/d_path.c:315:7: warning: no previous prototype for 'simple_dname' [-Wmissing-prototypes]
     315 | char *simple_dname(struct dentry *dentry, char *buffer, int buflen)
         |       ^~~~~~~~~~~~
   arch/x86/kernel/smpboot.c:298: warning: Function parameter or member 'phys_pkg' not described in 'topology_phys_to_logical_pkg'
   arch/x86/kernel/smpboot.c:316: warning: Function parameter or member 'die_id' not described in 'topology_phys_to_logical_die'
   arch/x86/kernel/smpboot.c:316: warning: Function parameter or member 'cur_cpu' not described in 'topology_phys_to_logical_die'
   kernel/context_tracking.c:63: warning: Function parameter or member 'state' not described in '__context_tracking_enter'
   kernel/context_tracking.c:63: warning: expecting prototype for context_tracking_enter(). Prototype was for __context_tracking_enter() instead
   kernel/context_tracking.c:147: warning: Function parameter or member 'state' not described in '__context_tracking_exit'
   kernel/context_tracking.c:147: warning: expecting prototype for context_tracking_exit(). Prototype was for __context_tracking_exit() instead
   drivers/base/module.c: In function 'module_add_driver':
   drivers/base/module.c:36:6: warning: variable 'no_warn' set but not used [-Wunused-but-set-variable]
      36 |  int no_warn;
         |      ^~~~~~~
   fs/nsfs.c:264: warning: Function parameter or member 'ns' not described in 'ns_match'
   fs/nsfs.c:264: warning: Excess function parameter 'ns_common' description in 'ns_match'
   fs/fs_context.c:145: warning: Function parameter or member 'fc' not described in 'vfs_parse_fs_string'
   fs/fs_context.c:145: warning: Function parameter or member 'key' not described in 'vfs_parse_fs_string'
   fs/fs_context.c:145: warning: Function parameter or member 'value' not described in 'vfs_parse_fs_string'
   fs/fs_context.c:145: warning: Function parameter or member 'v_size' not described in 'vfs_parse_fs_string'
   fs/fs_context.c:179: warning: Function parameter or member 'fc' not described in 'generic_parse_monolithic'
   fs/fs_context.c:179: warning: Excess function parameter 'ctx' description in 'generic_parse_monolithic'
   fs/fs_context.c:317: warning: expecting prototype for vfs_dup_fc_config(). Prototype was for vfs_dup_fs_context() instead
   fs/fs_context.c:363: warning: Function parameter or member 'log' not described in 'logfc'
   fs/fs_context.c:363: warning: Function parameter or member 'prefix' not described in 'logfc'
   fs/fs_context.c:363: warning: Function parameter or member 'level' not described in 'logfc'
   fs/fs_context.c:363: warning: Excess function parameter 'fc' description in 'logfc'
   drivers/firewire/init_ohci1394_dma.c:178: warning: Function parameter or member 'ohci' not described in 'init_ohci1394_wait_for_busresets'
   drivers/firewire/init_ohci1394_dma.c:196: warning: Function parameter or member 'ohci' not described in 'init_ohci1394_enable_physical_dma'
   drivers/firewire/init_ohci1394_dma.c:207: warning: Function parameter or member 'ohci' not described in 'init_ohci1394_reset_and_init_dma'
   drivers/firewire/init_ohci1394_dma.c:236: warning: Function parameter or member 'num' not described in 'init_ohci1394_controller'
   drivers/firewire/init_ohci1394_dma.c:236: warning: Function parameter or member 'slot' not described in 'init_ohci1394_controller'
   drivers/firewire/init_ohci1394_dma.c:236: warning: Function parameter or member 'func' not described in 'init_ohci1394_controller'
   drivers/firewire/init_ohci1394_dma.c:258: warning: expecting prototype for debug_init_ohci1394_dma(). Prototype was for init_ohci1394_dma_on_all_controllers() instead
   drivers/firewire/init_ohci1394_dma.c:289: warning: Function parameter or member 'opt' not described in 'setup_ohci1394_dma'
   drivers/firewire/init_ohci1394_dma.c:289: warning: expecting prototype for setup_init_ohci1394_early(). Prototype was for setup_ohci1394_dma() instead
   arch/x86/kernel/crash_dump_64.c:70: warning: Function parameter or member 'pfn' not described in 'copy_oldmem_page_encrypted'
   arch/x86/kernel/crash_dump_64.c:70: warning: Function parameter or member 'buf' not described in 'copy_oldmem_page_encrypted'
   arch/x86/kernel/crash_dump_64.c:70: warning: Function parameter or member 'csize' not described in 'copy_oldmem_page_encrypted'
   arch/x86/kernel/crash_dump_64.c:70: warning: Function parameter or member 'offset' not described in 'copy_oldmem_page_encrypted'
   arch/x86/kernel/crash_dump_64.c:70: warning: Function parameter or member 'userbuf' not described in 'copy_oldmem_page_encrypted'
   fs/kernel_read_file.c:38: warning: Function parameter or member 'file' not described in 'kernel_read_file'
   fs/kernel_read_file.c:38: warning: Function parameter or member 'offset' not described in 'kernel_read_file'
   fs/kernel_read_file.c:38: warning: Function parameter or member 'buf' not described in 'kernel_read_file'
   fs/kernel_read_file.c:38: warning: Function parameter or member 'buf_size' not described in 'kernel_read_file'
   fs/kernel_read_file.c:38: warning: Function parameter or member 'file_size' not described in 'kernel_read_file'
   fs/kernel_read_file.c:38: warning: Function parameter or member 'id' not described in 'kernel_read_file'
   lib/errname.c:16:67: warning: initialized field overwritten [-Woverride-init]
      16 | #define E(err) [err + BUILD_BUG_ON_ZERO(err <= 0 || err > 300)] = "-" #err
         |                                                                   ^~~
   lib/errname.c:173:2: note: in expansion of macro 'E'
     173 |  E(EDEADLK), /* EDEADLOCK */
         |  ^
   lib/errname.c:16:67: note: (near initialization for 'names_0[35]')
      16 | #define E(err) [err + BUILD_BUG_ON_ZERO(err <= 0 || err > 300)] = "-" #err
         |                                                                   ^~~
   lib/errname.c:173:2: note: in expansion of macro 'E'
     173 |  E(EDEADLK), /* EDEADLOCK */
         |  ^
   drivers/rtc/sysfs.c:115: warning: expecting prototype for rtc_sysfs_show_hctosys(). Prototype was for hctosys_show() instead
   drivers/acpi/x86/apple.c:27:6: warning: no previous prototype for 'acpi_extract_apple_properties' [-Wmissing-prototypes]
      27 | void acpi_extract_apple_properties(struct acpi_device *adev)
         |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   lib/nlattr.c:648: warning: Function parameter or member 'p' not described in 'nla_policy_len'
   lib/nlattr.c:648: warning: Excess function parameter 'policy' description in 'nla_policy_len'
   drivers/usb/typec/ucsi/ucsi.c:1288: warning: expecting prototype for ucsi_get_drvdata(). Prototype was for ucsi_set_drvdata() instead
   drivers/acpi/acpi_lpit.c:148:6: warning: no previous prototype for 'acpi_init_lpit' [-Wmissing-prototypes]
     148 | void acpi_init_lpit(void)
         |      ^~~~~~~~~~~~~~
   drivers/usb/host/xhci.c: In function 'xhci_unmap_temp_buf':
   drivers/usb/host/xhci.c:1349:15: warning: variable 'len' set but not used [-Wunused-but-set-variable]
    1349 |  unsigned int len;
         |               ^~~
   drivers/acpi/acpi_watchdog.c:85: warning: This comment starts with '/**', but isn't a kernel-doc comment. Refer Documentation/doc-guide/kernel-doc.rst
    * Returns true if this system should prefer ACPI based watchdog instead of
   drivers/usb/host/xhci.c:1425: warning: Function parameter or member 'desc' not described in 'xhci_get_endpoint_index'
   drivers/acpi/processor_idle.c:1097:12: warning: no previous prototype for 'acpi_processor_ffh_lpi_probe' [-Wmissing-prototypes]
    1097 | int __weak acpi_processor_ffh_lpi_probe(unsigned int cpu)
         |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/acpi/processor_idle.c:1102:12: warning: no previous prototype for 'acpi_processor_ffh_lpi_enter' [-Wmissing-prototypes]
    1102 | int __weak acpi_processor_ffh_lpi_enter(struct acpi_lpi_state *lpi)
         |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/posix_acl.c: In function 'get_acl':
   fs/posix_acl.c:127:22: warning: suggest braces around empty body in an 'if' statement [-Wempty-body]
     127 |   /* fall through */ ;
         |                      ^
   drivers/net/ethernet/realtek/r8169_main.c: In function 'r8169_mdio_register':
>> drivers/net/ethernet/realtek/r8169_main.c:5090:13: error: 'struct pci_bus' has no member named 'domain_nr'
    5090 |    pdev->bus->domain_nr, pci_dev_id(pdev));
         |             ^~
   drivers/thermal/thermal_core.c:1376: warning: expecting prototype for thermal_device_unregister(). Prototype was for thermal_zone_device_unregister() instead
   make[5]: *** [scripts/Makefile.build:272: drivers/net/ethernet/realtek/r8169_main.o] Error 1
   make[5]: Target '__build' not remade because of errors.
   make[4]: *** [scripts/Makefile.build:515: drivers/net/ethernet/realtek] Error 2
   drivers/acpi/ioapic.c:212:6: warning: no previous prototype for 'pci_ioapic_remove' [-Wmissing-prototypes]
     212 | void pci_ioapic_remove(struct acpi_pci_root *root)
         |      ^~~~~~~~~~~~~~~~~
   drivers/acpi/ioapic.c:229:5: warning: no previous prototype for 'acpi_ioapic_remove' [-Wmissing-prototypes]
     229 | int acpi_ioapic_remove(struct acpi_pci_root *root)
         |     ^~~~~~~~~~~~~~~~~~
   drivers/cpuidle/sysfs.c:511: warning: expecting prototype for cpuidle_remove_driver_sysfs(). Prototype was for cpuidle_remove_state_sysfs() instead
   drivers/leds/led-class.c:521: warning: Function parameter or member 'dev' not described in 'devm_led_classdev_unregister'
   drivers/leds/led-class.c:521: warning: Excess function parameter 'parent' description in 'devm_led_classdev_unregister'
   drivers/firmware/efi/efi.c:166:16: warning: no previous prototype for 'efi_attr_is_visible' [-Wmissing-prototypes]
     166 | umode_t __weak efi_attr_is_visible(struct kobject *kobj, struct attribute *attr,
         |                ^~~~~~~~~~~~~~~~~~~
   drivers/acpi/cppc_acpi.c:573: warning: Function parameter or member 'pcc_ss_id' not described in 'pcc_data_alloc'
   drivers/acpi/cppc_acpi.c:1356: warning: Function parameter or member 'cpu_num' not described in 'cppc_get_transition_latency'
   drivers/firmware/efi/memmap.c:201: warning: Function parameter or member 'addr' not described in 'efi_memmap_init_late'
   drivers/firmware/efi/memmap.c:201: warning: Excess function parameter 'phys_addr' description in 'efi_memmap_init_late'
   drivers/firmware/efi/memmap.c:236: warning: Function parameter or member 'data' not described in 'efi_memmap_install'
   drivers/firmware/efi/memmap.c:236: warning: Excess function parameter 'ctx' description in 'efi_memmap_install'
   make[4]: Target '__build' not remade because of errors.
   make[3]: *** [scripts/Makefile.build:515: drivers/net/ethernet] Error 2
   make[3]: Target '__build' not remade because of errors.
   make[2]: *** [scripts/Makefile.build:515: drivers/net] Error 2
   drivers/cpufreq/intel_pstate.c:257: warning: Function parameter or member 'epp_cached' not described in 'cpudata'
   drivers/firmware/efi/efi-pstore.c:225: warning: Function parameter or member 'record' not described in 'efi_pstore_read'
   drivers/firmware/efi/cper.c:587:6: warning: no previous prototype for 'cper_estatus_print' [-Wmissing-prototypes]
     587 | void cper_estatus_print(const char *pfx,
         |      ^~~~~~~~~~~~~~~~~~
   drivers/firmware/efi/cper.c:610:5: warning: no previous prototype for 'cper_estatus_check_header' [-Wmissing-prototypes]
     610 | int cper_estatus_check_header(const struct acpi_hest_generic_status *estatus)
         |     ^~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/firmware/efi/cper.c:623:5: warning: no previous prototype for 'cper_estatus_check' [-Wmissing-prototypes]
     623 | int cper_estatus_check(const struct acpi_hest_generic_status *estatus)
         |     ^~~~~~~~~~~~~~~~~~
   drivers/mailbox/pcc.c:179: warning: Function parameter or member 'irq' not described in 'pcc_mbox_irq'
   drivers/mailbox/pcc.c:179: warning: Function parameter or member 'p' not described in 'pcc_mbox_irq'
   drivers/mailbox/pcc.c:378: warning: expecting prototype for parse_pcc_subspaces(). Prototype was for parse_pcc_subspace() instead
   drivers/hwspinlock/hwspinlock_core.c:208: warning: Function parameter or member 'to' not described in '__hwspin_lock_timeout'
   drivers/hwspinlock/hwspinlock_core.c:208: warning: Excess function parameter 'timeout' description in '__hwspin_lock_timeout'
   drivers/hwspinlock/hwspinlock_core.c:318: warning: Excess function parameter 'bank' description in 'of_hwspin_lock_simple_xlate'
   drivers/hwspinlock/hwspinlock_core.c:647: warning: Function parameter or member 'hwlock' not described in '__hwspin_lock_request'
   drivers/hid/hid-magicmouse.c:135: warning: Function parameter or member 'hdev' not described in 'magicmouse_sc'
   drivers/hid/hid-magicmouse.c:135: warning: Function parameter or member 'work' not described in 'magicmouse_sc'
   make[2]: Target '__build' not remade because of errors.
   make[1]: *** [Makefile:1847: drivers] Error 2
   make[1]: Target 'vmlinux' not remade because of errors.
   make: *** [Makefile:215: __sub-make] Error 2
   make: Target 'vmlinux' not remade because of errors.


vim +5090 drivers/net/ethernet/realtek/r8169_main.c

  5074	
  5075	static int r8169_mdio_register(struct rtl8169_private *tp)
  5076	{
  5077		struct pci_dev *pdev = tp->pci_dev;
  5078		struct mii_bus *new_bus;
  5079		int ret;
  5080	
  5081		new_bus = devm_mdiobus_alloc(&pdev->dev);
  5082		if (!new_bus)
  5083			return -ENOMEM;
  5084	
  5085		new_bus->name = "r8169";
  5086		new_bus->priv = tp;
  5087		new_bus->parent = &pdev->dev;
  5088		new_bus->irq[0] = PHY_MAC_INTERRUPT;
  5089		snprintf(new_bus->id, MII_BUS_ID_SIZE, "r8169-%x-%x",
> 5090			 pdev->bus->domain_nr, pci_dev_id(pdev));
  5091	
  5092		new_bus->read = r8169_mdio_read_reg;
  5093		new_bus->write = r8169_mdio_write_reg;
  5094	
  5095		ret = devm_mdiobus_register(&pdev->dev, new_bus);
  5096		if (ret)
  5097			return ret;
  5098	
  5099		tp->phydev = mdiobus_get_phy(new_bus, 0);
  5100		if (!tp->phydev) {
  5101			return -ENODEV;
  5102		} else if (!tp->phydev->drv) {
  5103			/* Most chip versions fail with the genphy driver.
  5104			 * Therefore ensure that the dedicated PHY driver is loaded.
  5105			 */
  5106			dev_err(&pdev->dev, "no dedicated PHY driver found for PHY ID 0x%08x, maybe realtek.ko needs to be added to initramfs?\n",
  5107				tp->phydev->phy_id);
  5108			return -EUNATCH;
  5109		}
  5110	
  5111		tp->phydev->mac_managed_pm = 1;
  5112	
  5113		phy_support_asym_pause(tp->phydev);
  5114	
  5115		/* PHY will be woken up in rtl_open() */
  5116		phy_suspend(tp->phydev);
  5117	
  5118		return 0;
  5119	}
  5120	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Heiner Kallweit June 23, 2021, 7:48 p.m. UTC | #2
On 22.06.2021 14:52, Andre Przywara wrote:
> From: Sayanta Pattanayak <sayanta.pattanayak@arm.com>
> 
> When registering the MDIO bus for a r8169 device, we use the PCI B/D/F
> specifier as a (seemingly) unique device identifier.
> However the very same BDF number can be used on another PCI segment,
> which makes the driver fail probing:
> 
> [ 27.544136] r8169 0002:07:00.0: enabling device (0000 -> 0003)
> [ 27.559734] sysfs: cannot create duplicate filename '/class/mdio_bus/r8169-700'
> ....…
> [ 27.684858] libphy: mii_bus r8169-700 failed to register
> [ 27.695602] r8169: probe of 0002:07:00.0 failed with error -22
> 
> Add the segment number to the device name to make it more unique.
> 
> This fixes operation on an ARM N1SDP board, where two boards might be
> connected together to form an SMP system, and all on-board devices show
> up twice, just on different PCI segments.
> 
> Signed-off-by: Sayanta Pattanayak <sayanta.pattanayak@arm.com>
> [Andre: expand commit message]
> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
> ---
>  drivers/net/ethernet/realtek/r8169_main.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
> index 2c89cde7da1e..209dee295ce2 100644
> --- a/drivers/net/ethernet/realtek/r8169_main.c
> +++ b/drivers/net/ethernet/realtek/r8169_main.c
> @@ -5086,7 +5086,8 @@ static int r8169_mdio_register(struct rtl8169_private *tp)
>  	new_bus->priv = tp;
>  	new_bus->parent = &pdev->dev;
>  	new_bus->irq[0] = PHY_MAC_INTERRUPT;
> -	snprintf(new_bus->id, MII_BUS_ID_SIZE, "r8169-%x", pci_dev_id(pdev));
> +	snprintf(new_bus->id, MII_BUS_ID_SIZE, "r8169-%x-%x",
> +		 pdev->bus->domain_nr, pci_dev_id(pdev));
>  
I think you saw the error mail from kernel test robot.
You have to use pci_domain_nr() instead of member domain_nr directly.

>  	new_bus->read = r8169_mdio_read_reg;
>  	new_bus->write = r8169_mdio_write_reg;
>
Andre Przywara June 23, 2021, 9:43 p.m. UTC | #3
On Wed, 23 Jun 2021 21:48:14 +0200
Heiner Kallweit <hkallweit1@gmail.com> wrote:

Hi Heiner,

> On 22.06.2021 14:52, Andre Przywara wrote:
> > From: Sayanta Pattanayak <sayanta.pattanayak@arm.com>
> > 
> > When registering the MDIO bus for a r8169 device, we use the PCI B/D/F
> > specifier as a (seemingly) unique device identifier.
> > However the very same BDF number can be used on another PCI segment,
> > which makes the driver fail probing:
> > 
> > [ 27.544136] r8169 0002:07:00.0: enabling device (0000 -> 0003)
> > [ 27.559734] sysfs: cannot create duplicate filename '/class/mdio_bus/r8169-700'
> > ....…
> > [ 27.684858] libphy: mii_bus r8169-700 failed to register
> > [ 27.695602] r8169: probe of 0002:07:00.0 failed with error -22
> > 
> > Add the segment number to the device name to make it more unique.
> > 
> > This fixes operation on an ARM N1SDP board, where two boards might be
> > connected together to form an SMP system, and all on-board devices show
> > up twice, just on different PCI segments.
> > 
> > Signed-off-by: Sayanta Pattanayak <sayanta.pattanayak@arm.com>
> > [Andre: expand commit message]
> > Signed-off-by: Andre Przywara <andre.przywara@arm.com>
> > ---
> >  drivers/net/ethernet/realtek/r8169_main.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
> > index 2c89cde7da1e..209dee295ce2 100644
> > --- a/drivers/net/ethernet/realtek/r8169_main.c
> > +++ b/drivers/net/ethernet/realtek/r8169_main.c
> > @@ -5086,7 +5086,8 @@ static int r8169_mdio_register(struct rtl8169_private *tp)
> >  	new_bus->priv = tp;
> >  	new_bus->parent = &pdev->dev;
> >  	new_bus->irq[0] = PHY_MAC_INTERRUPT;
> > -	snprintf(new_bus->id, MII_BUS_ID_SIZE, "r8169-%x", pci_dev_id(pdev));
> > +	snprintf(new_bus->id, MII_BUS_ID_SIZE, "r8169-%x-%x",
> > +		 pdev->bus->domain_nr, pci_dev_id(pdev));
> >    
> I think you saw the error mail from kernel test robot.
> You have to use pci_domain_nr() instead of member domain_nr directly.

Yeah, thanks, I figured already. I actually missed test-compiling for
x86 :-(

Will send v2 ASAP.

Cheers,
Andre

> 
> >  	new_bus->read = r8169_mdio_read_reg;
> >  	new_bus->write = r8169_mdio_write_reg;
> >   
>
diff mbox series

Patch

diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
index 2c89cde7da1e..209dee295ce2 100644
--- a/drivers/net/ethernet/realtek/r8169_main.c
+++ b/drivers/net/ethernet/realtek/r8169_main.c
@@ -5086,7 +5086,8 @@  static int r8169_mdio_register(struct rtl8169_private *tp)
 	new_bus->priv = tp;
 	new_bus->parent = &pdev->dev;
 	new_bus->irq[0] = PHY_MAC_INTERRUPT;
-	snprintf(new_bus->id, MII_BUS_ID_SIZE, "r8169-%x", pci_dev_id(pdev));
+	snprintf(new_bus->id, MII_BUS_ID_SIZE, "r8169-%x-%x",
+		 pdev->bus->domain_nr, pci_dev_id(pdev));
 
 	new_bus->read = r8169_mdio_read_reg;
 	new_bus->write = r8169_mdio_write_reg;