[PATCH] Separate pci bits out of struct device_node

John Rose johnrose at austin.ibm.com
Wed Oct 5 06:47:12 EST 2005


Hi Paul-

> diff -urN linux-2.6/arch/ppc64/kernel/pci_dn.c pcidn/arch/ppc64/kernel/pci_dn.c
> --- linux-2.6/arch/ppc64/kernel/pci_dn.c	2005-04-26 15:37:55.000000000 +1000
> +++ pcidn/arch/ppc64/kernel/pci_dn.c	2005-09-06 11:39:47.000000000 +1000
...
> @@ -40,16 +42,26 @@
>  	struct pci_controller *phb = data;
>  	int *type = (int *)get_property(dn, "ibm,pci-config-space-type", NULL);
>  	u32 *regs;
> +	struct pci_dn *pdn;
>  
> -	dn->phb = phb;
> +	if (phb->is_dynamic)
> +		pdn = kmalloc(sizeof(*pdn), GFP_KERNEL);
> +	else
> +		pdn = alloc_bootmem(sizeof(*pdn));

I didn't notice it at first, but this check seems incorrect.  The
phb->is_dynamic flag indicates whether a PHB was present at boot.  

Suppose I try to hotplug add a device to a slot with a parent PHB that
was present at boot.  This code path gets called for every dynamic
device node add.  With this as-is, we get a runtime call to
alloc_bootmem() for the new device nodes - crash.  Linas reported this:
http://www.ussg.iu.edu/hypermail/linux/kernel/0510.0/0510.html

It would seem that the check should be asking whether we are at boot or
not, and this flag probably isn't the one for that.  I don't know
whether mem_init_done is a better idea.  This goes back to the "global
var vs. init/dynamic versions of allocs" debate, for which we have
historically followed the latter.

Thoughts?

Thanks-
John




More information about the Linuxppc64-dev mailing list