Subject: Re: [PATCH 9/16] Supporting of PCI bus for Celleb

From: Christoph Hellwig <[email-masked]>
Date: Wed, 15 Nov 2006 19:43:28 +0100

> +static inline void ioif_setup(struct ioif *ioif, struct device_node *dn)
> +{
> +	ioif->iommu_table = NULL;
> +}
> +
> +struct ioif *ioif_alloc(struct device_node *dn)
> +{
> +	struct ioif *ioif;
> +
> +	if (mem_init_done)
> +		ioif = kmalloc(sizeof(struct ioif), GFP_KERNEL);
> +	else
> +		ioif = alloc_bootmem(sizeof(struct ioif));
> +
> +	if (ioif)
> +		ioif_setup(ioif, dn);
> +
> +	return ioif;

Please switch the above from kmalloc to kzalloc.  As alloc_bootmem also
zeroes it's return value you now have ioif pre-cleared and don't need
ioif_setup.  Also when can this be called from non-initialization code?

> +struct ioif {

Struct ioif is a bit too generic, can you give it a better name?

> +extern int 
> +__init celleb_setup_pci_bridge(struct device_node *, struct pci_controller *);

Please move this extern declaration to a header.

> +
> +static int 
> +celleb_dummy_pci_read_config(struct pci_bus *bus,
> +                             unsigned int devfn,
> +                             int where, int size, u32 *val)
> +{
> +
> +
> +	return PCIBIOS_DEVICE_NOT_FOUND;
> +}
> +
> +
> +static int 
> +celleb_dummy_pci_write_config(struct pci_bus *bus,
> +                              unsigned int devfn,
> +                              int where, int size, u32 val)
> +{
> +
> +	return PCIBIOS_DEVICE_NOT_FOUND;
> +}
> +
> +struct pci_ops celleb_dummy_pci_ops = {
> +/* for generic PCI buses/devices */
> +	celleb_dummy_pci_read_config,
> +	celleb_dummy_pci_write_config
> +};

This look broken to me.  Busses that do not support config space
cycles shouldn't be reported to the PCI layer at all.

> +struct pci_ops celleb_fake_pci_ops = {
> +	celleb_fake_pci_read_config,
> +	celleb_fake_pci_write_config
> +};

What are these fake ops for?  If you don't have a real PCI
bus you shouldn't emulate it but use a vio-style bus insted.