Re: [RFC][AGPGART]Allow multiple backends to be initialized

From: Christoph Hellwig
Date: Tue Dec 07 2004 - 04:05:34 EST


> -struct agp_bridge_data agp_bridge_dummy = { .type = NOT_SUPPORTED };
> -struct agp_bridge_data *agp_bridge = &agp_bridge_dummy;
> +agp_bridge_data_p agp_bridge;

Please don't intoroduce new new typedefs, especially not for pointer
types.

> +LIST_HEAD(agp_bridges);
> EXPORT_SYMBOL(agp_bridge);
> -
> +EXPORT_SYMBOL(agp_bridges);

> -int agp_backend_acquire(void)
> +int agp_backend_acquire(struct pci_dev *pdev, agp_bridge_data_p
> *acquired_bridge)
> {
> - if (agp_bridge->type == NOT_SUPPORTED)
> - return -EINVAL;
> - if (atomic_read(&agp_bridge->agp_in_use))
> + agp_bridge_data_p bridge;
> +
> + if (!pdev) {
> + if (!agp_bridge)
> + return -ENODEV;
> + bridge = agp_bridge;
> + } else {
> + list_for_each_entry(bridge, &agp_bridges, list) {
> + int match=0;
> + switch(pdev->class) {
> + /* Standard bridges have a valid pci_dev */
> + case PCI_CLASS_BRIDGE_HOST:
> + if (bridge->dev==pdev)
> + match=1;
> + break;
> + /* Non-standard bridges can use a devices pci_dev */
> + default:
> + if (bridge->dev->bus==pdev->bus)
> + match=1;
> + break;
> + }
> + if (match)
> + break;
> + }
> + }

Wrong interface. Please pass in the pci_dev of the grpahics cards and
add a new method for lowlevel drivers to find the bridge. For the normal
bridges (aka everything but the hp, alpha and your new driver) you'd do
a generic helper that just walks down the parent pointers until it finds
a class.

Also I'd suggest returning the found bridges as return value of the
function.

> - printk(KERN_INFO PFX "AGP aperture is %dM @ 0x%lx\n",
> - size_value, bridge->gart_bus_addr);
> + printk(KERN_INFO PFX "agp_bridge = 0x%lx: AGP aperture is %dM @ 0x%lx\n",
> + (unsigned long)bridge, size_value, bridge->gart_bus_addr);

pointers should be printed using %p, but this isn't a place where you should
print it at all.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/