Subject: Re: multi function PCI devices with shared registers
To: Johan Danielsson <>
From: Stefan Grefen <>
List: tech-kern
Date: 03/04/1999 18:09:40
In message <>  Johan Danielsson wrote:
> Let's say I have a PCI device with more than one function, and the
> device has some I/O map register that is shared between the two
> functions (that is the register points to the same io address).
> How can this be handled when attaching the device? I would like to get
> a pointer (or something) to the first function when attaching the
> second.
> The same problem arises with registers that `should be written only
> through function 0'.
> Is there some code that does something like this in the tree?

No code in the tree, but you can write a driver which probes the 
additional function as it likes (and just maps registers once, or
takes care of useing function 0 for certain things).

Basic code to do it :

In match return 1; only for fucntion 0 (or ignore the others in 

in ...attach:
	struct pci_attach_args *pa = aux,tpa[NDEVS];
	pci_chipset_tag_t pc = pa->pa_pc;

	for (i = 0 ;i <NDEVS ; i++) {
	    int bus,dev;
	    tpa[i] = *pa;

	    if (i) {


		tpa[i].pa_tag[i] = pci_make_tag(pc,bus,dev,i);

		tpa[i].pa_function = i;


Now you can all pci_mapreg_map(&tpa[i], ... ), and 
have valid tags etc.A


> /Johan

Stefan Grefen                                Tandem Computers Europe Inc.                       High Performance Research Center
 --- Hacking's just another word for nothing left to kludge. ---