From patchwork Mon Apr 10 11:58:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yongji Xie X-Patchwork-Id: 9672475 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9A46460244 for ; Mon, 10 Apr 2017 12:01:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 912321FF61 for ; Mon, 10 Apr 2017 12:01:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8500128449; Mon, 10 Apr 2017 12:01:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 266821FF61 for ; Mon, 10 Apr 2017 12:01:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753243AbdDJMBb (ORCPT ); Mon, 10 Apr 2017 08:01:31 -0400 Received: from mail-pg0-f67.google.com ([74.125.83.67]:35508 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752955AbdDJMBa (ORCPT ); Mon, 10 Apr 2017 08:01:30 -0400 Received: by mail-pg0-f67.google.com with SMTP id g2so25440398pge.2 for ; Mon, 10 Apr 2017 05:01:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=o+6qwYNaesChJ91rTEEBmN09d1tkv40cMEKS8tmF2gg=; b=Kk0VGj0Ga/XBGxEMb/pPpOyKOdZz3CaCylGRmC6WBFE0cXuqg0Gw24q5OCW+/Q/MhE Le4iH2OeoHW0jw7opdtAQ64+92SfPU8G8Nf3EtVjwJij9jVvLvSFrbMjicde4VoayjEt dN2qtWMijm+Q8EdOBh2M70i4CAOYJGGVsrtk+rze1PvG1C2Hmj8nhRSYIH2w1zmAOQyP l3fJt50fm9wooviBN6spb/ULWAyd+SuPYbDp1M88P+l9m9Ny5wvRRc2r6fa69/qiJ6wp 1w6fxiCfOcT0H4RQLMV/CCu5iXQMrOjGc/Pg9wG0pyAvagwWjltRFe/SNQ1hfaYhaPZJ 1wUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=o+6qwYNaesChJ91rTEEBmN09d1tkv40cMEKS8tmF2gg=; b=iiSxemQplnz46wOog7Bb39dWTI7scO7aVeUx4opsISdJD0zfseULFIoVS7Cr7RH8zc Y+Sr+cw7I61V3PMEq5VkNV/3WKyzPV1RYw5GLe9Tm0LutOWr0p2XVkNGF38rwaRVDRmI jiv7hUO58hXnT693CsT54CUKbU9lnI27RhWfmIqNXFAf++WPXAZv7o+Sl/5rQ68JmN/R y6WKhq+s7qiMWLPN5EmNDpKMmfEi08WouyaVlaeJLkAxM+Dorfm91jACBaH7QsrxhB2w 78b0BszRDxCYYQLeI1qoaY+wJjv1bXVAyPENaqYHmxWnO9YyXJI6NpdFGMc0g06QBkm6 3BHQ== X-Gm-Message-State: AFeK/H2jZxJR60l9APVirnyXl7ueop2Jd7U79+RcnyIqXAXu2dP/0PiyPw4TYUjj0yKylw== X-Received: by 10.84.197.1 with SMTP id m1mr67580185pld.183.1491825689649; Mon, 10 Apr 2017 05:01:29 -0700 (PDT) Received: from localhost ([116.247.112.152]) by smtp.gmail.com with ESMTPSA id d1sm24498470pfa.5.2017.04.10.05.01.28 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Mon, 10 Apr 2017 05:01:29 -0700 (PDT) From: Yongji Xie To: bhelgaas@google.com Cc: linux-pci@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, alex.williamson@redhat.com, gwshan@linux.vnet.ibm.com, aik@ozlabs.ru, benh@kernel.crashing.org, mpe@ellerman.id.au, paulus@samba.org, zhong@linux.vnet.ibm.com Subject: [PATCH v10 1/4] PCI: A fix for caculating bridge window's size and alignment Date: Mon, 10 Apr 2017 19:58:11 +0800 Message-Id: <1491825494-19331-2-git-send-email-elohimes@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1491825494-19331-1-git-send-email-elohimes@gmail.com> References: <1491825494-19331-1-git-send-email-elohimes@gmail.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In case that one device's alignment is greater than its size, we may get an incorrect size and alignment for its bus's memory window in pbus_size_mem(). This patch fixes this case. Signed-off-by: Yongji Xie --- drivers/pci/setup-bus.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index cb389277..958da7d 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c @@ -1066,10 +1066,10 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask, r->flags = 0; continue; } - size += r_size; + size += max(r_size, align); /* Exclude ranges with size > align from calculation of the alignment. */ - if (r_size == align) + if (r_size <= align) aligns[order] += align; if (order > max_order) max_order = order;