Re: [PATCH 1/1 v4] PCI: allocate essential resources before reservinghotplug resources
From: Yinghai Lu
Date: Thu Jan 20 2011 - 20:22:11 EST
On Wed, Jan 19, 2011 at 5:00 PM, Ram Pai <linuxram@xxxxxxxxxx> wrote:
> PCI: pre-allocate additional resources to devices only after successful
> allocation of essential resources.
>
> Linux tries to pre-allocate minimal resources to hotplug bridges. This
> works fine as long as there are enough resources to satisfy all other
> genuine resource requirements. However if enough resources are not
> available to satisfy any of these nice-to-have pre-allocations, the
> resource-allocator reports errors and returns failure.
>
> This patch distinguishes between must-have resource from nice-to-have
> resource. Any failure to allocate nice-to-have resources are ignored.
>
> This behavior can be particularly useful to trigger automatic
> reallocation when the OS discovers genuine allocation-conflicts
> or genuine unallocated-requests caused by buggy allocation behavior
> of the native BIOS/uEFI.
>
> https://bugzilla.kernel.org/show_bug.cgi?id=15960 captures the movitation
> behind the patch.
>
> changelog v2: o fixed a bug where pci_assign_resource() was called on a
> resource of zero resource size.
>
> changelog v3: addressed Bjorn's comment
> o "Please don't indent and right-justify the changelog".
> o removed add_size from struct resource. The additional
> size is now tracked using a linked list.
>
> changelog v4: o moved freeing up of elements of head list from
> assign_requested_resources_sorted() to
> __assign_resources_sorted(). This fixes a corruption bug.
> o removed a wrong reference to 'add_size' in
> pbus_size_mem(). Erroneously got introduced while
> generating the patch.
> o some code optimizations in adjust_resources_sorted()
> and assign_requested_resources_sorted()
>
> Signed-off-by: Ram Pai <linuxram@xxxxxxxxxx>
>
> diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
> index 66cb8f4..efbdff2 100644
> --- a/drivers/pci/setup-bus.c
> +++ b/drivers/pci/setup-bus.c
> @@ -33,11 +33,23 @@ struct resource_list_x {
> struct pci_dev *dev;
> resource_size_t start;
> resource_size_t end;
> + resource_size_t add_size;
> unsigned long flags;
> };
>
> -static void add_to_failed_list(struct resource_list_x *head,
> - struct pci_dev *dev, struct resource *res)
> +#define free_list(type, head) do { \
> + struct type *list, *tmp; \
> + for (list = (head)->next; list;) { \
> + tmp = list; \
> + list = list->next; \
> + kfree(tmp); \
> + } \
> + (head)->next = NULL; \
> +} while (0)
inline function should be better?
Yinghai
--
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/