request resources at init time vs open time

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi!
I'm writing some network device drivers (some ISA, some PCI) and would
like to understand when to request_mem_region(), ioremap(),
pci_enable_device(), etc... on module init, or on open?

LDD3 says one should not grab resources on init, but on open instead,
which makes perfect sense to me.  However, (almost) all network device
drivers in the kernel grab their resources (except irq) on init.
Why is that?

I guess that, for ISA devices, one has to request resources on init
to probe for the device anyway, so they might as well stay allocated,
instead of releasing and then requesting again on open.  Would that be
acceptable?

For PCI devices, probing is simpler, or even unnecessary, so I guess
it would be easy (desireable?) to just call pci_enable_device(),
request_region(), ioremap(), etc... on open.  But I noticed that's
not the usual practice for network device drivers in the kernel,
which do it all on init...  I'm confused.

I also wonder if the __init and __exit prefixes have a say about this...
I suppose doing all requests on __init functions and all releases
on __exit functions might save some memory?!?

I would like to understand the advantages and disadvantages of grabbing
resources on init, versus on open, so I can do it "the right way"! ;-)
Or is this whole issue not that important, and both methods are fine?

Thanks!
--
André Oliveira


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux