Re: [PATCH 01/40] PCI: fix default vga ref_count

From: Yinghai Lu
Date: Fri Sep 21 2012 - 17:17:58 EST


On Fri, Sep 21, 2012 at 1:52 PM, Bjorn Helgaas <bhelgaas@xxxxxxxxxx> wrote:
> On Wed, Sep 19, 2012 at 12:54 PM, Yinghai Lu <yinghai@xxxxxxxxxx> wrote:
>> --- a/drivers/gpu/vga/vgaarb.c
>> +++ b/drivers/gpu/vga/vgaarb.c
>> @@ -141,6 +141,12 @@ EXPORT_SYMBOL_GPL(vga_default_device);
>>
>> void vga_set_default_device(struct pci_dev *pdev)
>> {
>> + if (vga_default)
>> + pci_dev_put(vga_default);
>> +
>> + if (pdev)
>> + pdev = pci_dev_get(pdev);
>> +
>> vga_default = pdev;
>
> I think this is equivalent to:
>
> pci_dev_put(vga_default);
> vga_default = pci_dev_get(pdev);

ah, i missed that, pci_dev_put and pci_dev_get check that inside.

>
> I haven't seen an answer to Matthew's question about whether we want
> to check for "vga_default == pdev".

yes, that could avoid the extra put/get pair.

Please check updated version.

-Yinghai

Attachment: fix_vgarab_add_x.patch
Description: Binary data