Re: [PATCH] pci: Allow very large resource windows

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jul 10, 2014 at 7:12 PM, Yinghai Lu <yinghai@xxxxxxxxxx> wrote:
> On Thu, Jul 3, 2014 at 3:11 PM, Bjorn Helgaas <bhelgaas@xxxxxxxxxx> wrote:
>> On Thu, Jul 03, 2014 at 12:59:21PM -0700, Yinghai Lu wrote:
>
>>> when we try to size it,  means that bar is not assigned. with r->flags
>>> = 0, means
>>> we will ignore it all the way.
>>
>> With "r->flags = 0", we will not try to assign resources to the BAR,
>> but the hardware BAR still exists and contains some address.  If the
>> device has other memory BARs, pci_enable_resources() will turn on
>> PCI_COMMAND_MEMORY.  Now the "r->flags == 0" BAR is enabled but the
>> address it contains might conflict with other devices.  That's the
>> problem.
>>
>> To fix this, I think we need to do "r->flags |= IORESOURCE_UNSET |
>> IORESOURCE_DISABLED".
>
> No, that is not right.
>
> Current that r->flags = 0 and reset_resource() cover the bug in
> pci_enable_resources() when assign and reassign resource fail.
>
> In pci_enable_resources() if there is one resource with IO BAR or SRIOV BAR
> is not assigned and have UNSET, it will prevent device from being enabled.
>
> Most drivers could work without io port.
>
> If you change r->flags = 0 to
> r->flags |= IORESOURCE_UNSET | IORESOURCE_DISABLED
>
> Those drivers would not work anymore.

If a driver doesn't need IO ports, it should use
pci_enable_device_mem().  Then pci_enable_device_flags() will build a
BAR bitmask that does not include the IO BARs, and
pci_enable_resources() will not look at the resources corresponding to
those BARs at all (so it doesn't matter what r->flags is), and it will
not turn on PCI_COMMAND_IO.

> I also know one driver that could work with pref mmio, but mmio is not assigned.
> --- silicon bug, that it exposes non-needed mmio bar.

The driver might work, but turning on PCI_COMMAND_MEMORY when an MMIO
BAR is not assigned is dangerous and could cause bus conflicts.  If we
can't safely turn on PCI_COMMAND_MEMORY and this driver stops working,
well, I think that's tough luck.

I explained why I think it is dangerous in the paragraph "With
'r->flags = 0', ..." above.  This a question of how the hardware
behaves, so if you think I'm wrong, you need to point out something in
the spec that says the hardware works differently than how I think it
does.

> BTW I think we may need to clear the BAR in pci_claim_resource().
>
> Maybe Linus or Greg have more idea about this.
> Do we need to get more strict? will only enable PCI_COMMAND_MEMORY
> unless all mmio BARs get assigned value?

I think we should turn on PCI_COMMAND_MEMORY only when the driver
requests IORESOURCE_MEM and all MMIO BARs are assigned.

Bjorn
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux