[SeaBIOS] [PATCH 1/6] pci: don't reorder entries when moving to 64bit list
Kevin O'Connor
kevin at koconnor.net
Wed Nov 27 04:03:33 CET 2013
On Tue, Nov 26, 2013 at 01:24:09PM +0100, Gerd Hoffmann wrote:
> Otherwise the 64bit bars are not mapped in largest
> first order, thereby messing up the alignment.
>
> Signed-off-by: Gerd Hoffmann <kraxel at redhat.com>
> ---
> src/fw/pciinit.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/src/fw/pciinit.c b/src/fw/pciinit.c
> index 34279a4..84bb65b 100644
> --- a/src/fw/pciinit.c
> +++ b/src/fw/pciinit.c
> @@ -574,14 +574,19 @@ static u64 pci_region_sum(struct pci_region *r)
> static void pci_region_migrate_64bit_entries(struct pci_region *from,
> struct pci_region *to)
> {
> - struct hlist_node *n, **last = &to->list.first;
> + struct hlist_node *n, *last = NULL;
> struct pci_region_entry *entry;
> hlist_for_each_entry_safe(entry, n, &from->list, node) {
> if (!entry->is64)
> continue;
> // Move from source list to destination list.
> hlist_del(&entry->node);
> - hlist_add(&entry->node, last);
> + if (hlist_empty(&to->list)) {
> + hlist_add_head(&entry->node, &to->list);
> + } else {
> + hlist_add_after(&entry->node, last);
> + }
> + last = &entry->node;
This could be done by just adding: last = &entry->node.next;
However, this pattern seems to be common in the code and hard to
follow, so maybe a new macro should be added and the code refactored
to be more like what you have.
-Kevin
More information about the SeaBIOS
mailing list