Page 1 of 1

pci_register_driver std. linux function

Posted: Fri Oct 02, 2020 11:59 am
by ggodw000
I am inspecting linux driver code.
During initialization triggered by module_init(<driver_name>), at some point in later stage, the pci_register_driver is called. This is a part of linux kernel module I found. The first parameter is a linux driver structure which also must be standard.
There are members initialized for pci driver, including usual stuff like pci dev, vendor id.
The one I am paying attention to is .probe member and it is assigned to a function called <driver_name_probe>.

From the dmesg log after driver built and loaded, I can see <driver_name_probe> output sometime after registration.
What I am not sure in this instance is whether <driver_name_probe> is called as a result of, or during pci_register_driver or some other scheduling mechanism later once it is registered?

Does anyone have better knowledge on this?
I am too lazy to look at what pci_register_device is doing but earlier I did, there is at least one call to kobject_uevent() during registration which may possible hold the key.

The usual struc for pci driver:

static struct pci_driver <driver_name>_driver = {
.name = <driver_name>_driver_name,
.id_table = <driver_name>_pci_tbl,
.probe = <driver_name>probe,
.remove = <driver_name>remove,
.shutdown = <driver_name>shutdown,
.err_handler = &<driver_name>_err_handler
};

Re: pci_register_driver std. linux function

Posted: Fri Oct 02, 2020 4:09 pm
by Octocontrabass
ggodw000 wrote:What I am not sure in this instance is whether <driver_name_probe> is called as a result of, or during pci_register_driver or some other scheduling mechanism later once it is registered?
I found this documentation that seems to explain it.

Re: pci_register_driver std. linux function

Posted: Tue Oct 13, 2020 12:26 am
by ggodw000
yeah i looked at it.