Re: PCI probing in the kernel

From: Warner Losh <imp_at_bsdimp.com>
Date: Sat, 26 Jun 2021 05:43:26 UTC
On Fri, Jun 25, 2021, 11:15 PM <saimabaig11@gmail.com> wrote:

> It specifically says **em** probing and then it calls the **em_register**
> function repeatedly which is the registration routine that the em driver
> defines as part of its initialization.
>

The log you sent just shows em_register once.

This is whats confusing me  as to why is it repeatedly calling these
> functions for a specific module repeatedly
>
It calls em probe 6 times, finds one and call em_register, then calls em
probe 6 more times.

Warner

*From:* Warner Losh <imp@bsdimp.com>
> *Sent:* Saturday, June 26, 2021 10:40 AM
> *To:* saimabaig11@gmail.com
> *Cc:* FreeBSD Hackers <freebsd-hackers@freebsd.org>
> *Subject:* Re: PCI probing in the kernel
>
>
>
>
>
>
>
> On Fri, Jun 25, 2021 at 10:59 PM <saimabaig11@gmail.com> wrote:
>
> My question relates to how does the kernel go about its business of
> discovering PCI devices (after boot time) . I am loading the e1000(em)
> driver by kldloading the `if_em` module. The kernel seems to be calling the
> probe routine multiple times. So the log below includes messages coming
> from
> the kernel and also includes my own debug logs.
>
>
>
> ```
>
> Jun 25 11:16:45 FreeBSD12 kernel: em probing
>
> Jun 25 11:16:45 FreeBSD12 syslogd: last message repeated 5 times
>
> Jun 25 11:16:45 FreeBSD12 kernel: em0: +++ Calling em_register
>
> Jun 25 11:16:45 FreeBSD12 kernel: em probing
>
> Jun 25 11:16:45 FreeBSD12 syslogd: last message repeated 5 times
>
> Jun 25 11:16:45 FreeBSD12 kernel: em0: +++ Calling em_register
>
> Jun 25 11:16:45 FreeBSD12 kernel: em probing
>
> Jun 25 11:16:45 FreeBSD12 kernel: em0: +++ Calling em_register
>
> Jun 25 11:16:45 FreeBSD12 kernel: em0: <Intel(R) PRO/1000 Network
> Connection> port 0x2000-0x203f mem
> 0xfd5c0000-0xfd5dffff,0xfdff0000-0xfdffffff irq 19 at device 1.0 on pci2
>
> Jun 25 11:16:45 FreeBSD12 kernel: em attaching
>
> Jun 25 11:16:45 FreeBSD12 kernel: em0: +++ Calling em_register
>
> Jun 25 11:17:34 FreeBSD12 kernel: em0: Using 2048 TX descriptors and 2048
> RX
> descriptors
>
> Jun 25 11:17:35 FreeBSD12 kernel: em probing
>
> Jun 25 11:17:35 FreeBSD12 syslogd: last message repeated 5 times
>
> Jun 25 11:17:35 FreeBSD12 kernel: em1: +++ Calling em_register
>
> Jun 25 11:17:35 FreeBSD12 kernel: em probing
>
> Jun 25 11:17:36 FreeBSD12 kernel: Base = 5ee7e000, Length = 8000
>
> ```
>
> It seems that the `probe->register` sequence seems to be getting repeated
> multiple times until the adapter is identified properly and its resources
> allocated. Isn't multiple registration a cause of concern? Or may something
> is wrong with the way I think. May be I am not getting it right? Could
> someone elaborate?
>
>
>
> When you load a driver, we call probe on all the devices on the bus that
> don't
>
> yet have drivers. I believe you are seeing this. The probe routine tries a
> bunch
>
> of different devices until finding the NIC that doesn't have a driver.
> It's completely
>
> normal and ordinary.
>
>
>
> Warner
>