lkml.org 
[lkml]   [2009]   [Jul]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    SubjectRe: [PATCH 1/2] vga: implements VGA arbitration on Linux
    From
    On Wed, Jul 15, 2009 at 12:35 AM, Alan Cox<alan@lxorguk.ukuu.org.uk> wrote:
    >> +#ifndef __ARCH_HAS_VGA_ENABLE_RESOURCES
    >> +static inline void vga_enable_resources(struct pci_dev *pdev,
    >> +                                     unsigned int rsrc)
    >> +{
    >> +     struct pci_bus *bus;
    >> +     struct pci_dev *bridge;
    >> +     u16 cmd;
    >> +
    >> +#ifdef DEBUG
    >> +     printk(KERN_DEBUG "%s\n", __func__);
    >> +#endif
    >> +     pci_read_config_word(pdev, PCI_COMMAND, &cmd);
    >> +     if (rsrc & (VGA_RSRC_LEGACY_IO | VGA_RSRC_NORMAL_IO))
    >> +             cmd |= PCI_COMMAND_IO;
    >> +     if (rsrc & (VGA_RSRC_LEGACY_MEM | VGA_RSRC_NORMAL_MEM))
    >> +             cmd |= PCI_COMMAND_MEMORY;
    >> +     pci_write_config_word(pdev, PCI_COMMAND, cmd);
    >
    > Locking question - what locks this lot against hotplug also touching
    > bridge settings ?
    >
    >> +
    >> +     if (!(rsrc & VGA_RSRC_LEGACY_MASK))
    >> +             return;
    >> +
    >> +     bus = pdev->bus;
    >> +     while (bus) {
    >> +             bridge = bus->self;
    >> +             if (bridge) {
    >> +                     pci_read_config_word(bridge, PCI_BRIDGE_CONTROL,
    >> +                                          &cmd);
    >> +                     if (!(cmd & PCI_BRIDGE_CTL_VGA)) {
    >> +                             cmd |= PCI_BRIDGE_CTL_VGA;
    >> +                             pci_write_config_word(bridge,
    >> +                                                   PCI_BRIDGE_CONTROL,
    >> +                                                   cmd);
    >> +                     }
    >> +             }
    >> +             bus = bus->parent;
    >> +     }
    >> +}
    >> +#endif
    >
    >
    >> +     /* The one who calls us should check for this, but lets be sure... */
    >> +     if (pdev == NULL)
    >> +             pdev = vga_default_device();
    >
    > What if the BIOS provided device was hot unplugged ?
    >
    >> +             conflict = __vga_tryget(vgadev, rsrc);
    >> +             spin_unlock_irqrestore(&vga_lock, flags);
    >> +             if (conflict == NULL)
    >> +                     break;
    >> +
    >> +
    >> +             /* We have a conflict, we wait until somebody kicks the
    >> +              * work queue. Currently we have one work queue that we
    >
    > If two drivers own half the resources and both are waiting for the rest
    > what handles the deadlock

    I'm not sure we should care about resource locking granularity below,
    I have all resources, I have no resources, I don't think we gain anything
    by it, since really we want to avoid using vga arb as much as we can.

    Tiago, the other issue I noticed when using this is we need to provide
    a hook for drm drivers that use an irq to have the irq disabled around
    the mem/io space disables otherwise they can get an irq with no mem/io
    and boom all fall down.

    Old X userspace RAC never worried about interrupts and assumed the
    GPU wasn't using one which was true in the 80s.

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

    \
     
     \ /
      Last update: 2009-07-15 06:45    [W:0.047 / U:122.344 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site