Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751842AbbHQXwn (ORCPT ); Mon, 17 Aug 2015 19:52:43 -0400 Received: from mail-pd0-f178.google.com ([209.85.192.178]:36179 "EHLO mail-pd0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751143AbbHQXwm (ORCPT ); Mon, 17 Aug 2015 19:52:42 -0400 Date: Mon, 17 Aug 2015 18:52:36 -0500 From: Bjorn Helgaas To: Yinghai Lu Cc: David Miller , Benjamin Herrenschmidt , Wei Yang , TJ , Yijing Wang , Andrew Morton , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 07/51] PCI: Reorder resources list for must/optional resources Message-ID: <20150817235236.GQ26431@google.com> References: <1438039809-24957-1-git-send-email-yinghai@kernel.org> <1438039809-24957-8-git-send-email-yinghai@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1438039809-24957-8-git-send-email-yinghai@kernel.org> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2029 Lines: 58 On Mon, Jul 27, 2015 at 04:29:25PM -0700, Yinghai Lu wrote: > After we update size and alignment for must+optional resource, we > reorder them with new alignment, but this is only for STARTALIGN. > > For SIZEALIGN type resource, after add back add_size, the alignment > get changed, so need to do the sorting like STARTALIGN type resources. > > Also we need to reorder the sorting back after we restore > resource to must only when must+optional fail to allocate for all. > > So move out the reordering code from the loop to separated function, > and call it two times accordingly. > > Signed-off-by: Yinghai Lu > --- > drivers/pci/setup-bus.c | 62 +++++++++++++++++++++++++++++-------------------- > 1 file changed, 37 insertions(+), 25 deletions(-) > > diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c > index 7346bbf..6f2d508 100644 > --- a/drivers/pci/setup-bus.c > +++ b/drivers/pci/setup-bus.c > @@ -287,6 +287,31 @@ static inline void reset_resource(struct resource *res) > res->flags = 0; > } > > +static void __sort_resources(struct list_head *head) Why did you add "__" before the function name? > +{ > + struct pci_dev_resource *res1, *tmp_res, *res2; > + > + list_for_each_entry_safe(res1, tmp_res, head, list) { > + resource_size_t align1, size1, align2, size2; > + > + align1 = pci_resource_alignment(res1->dev, res1->res); > + size1 = resource_size(res1->res); > + > + /* reorder it */ > + list_for_each_entry(res2, head, list) { > + if (res2 == res1) > + break; > + > + align2 = pci_resource_alignment(res2->dev, res2->res); > + size2 = resource_size(res2->res); > + if (is_before(align1, size1, align2, size2)) { > + list_move_tail(&res1->list, &res2->list); > + break; > + } > + } > + } > +} -- 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/