From patchwork Wed Aug 8 05:48:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Chia-Lin Kao (AceLan)" X-Patchwork-Id: 10559555 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-2.web.codeaurora.org (Postfix) with ESMTP id 6CB1C1390 for ; Wed, 8 Aug 2018 05:48:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5134F2A36C for ; Wed, 8 Aug 2018 05:48:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 452D02A370; Wed, 8 Aug 2018 05:48:44 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 3C59E2A36C for ; Wed, 8 Aug 2018 05:48:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726697AbeHHIGk (ORCPT ); Wed, 8 Aug 2018 04:06:40 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:38995 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726680AbeHHIGj (ORCPT ); Wed, 8 Aug 2018 04:06:39 -0400 Received: by mail-pf1-f196.google.com with SMTP id j8-v6so573992pff.6; Tue, 07 Aug 2018 22:48:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id; bh=mqmsKdmpmH18HuQQqA8F7CXlaVTzN1hPGjeY3SioQmM=; b=CE8I6/5keVToP3ihAdX1qTJhtYT8BXwGJUxZpSQ7JwuREm3uNL4+f4A+qqUhRQEtvq MGiIByWqX/ujwOeNBZGO9QJtmFXyLToZ6/eepm9NBRwob4uv7E07XmsMjuezxYSti7p9 uGLiPX7HE4o3AciEmmV5rPu/GB93gMagvjLh4waQwODf8eP/k0khFQAscKuWOlJycpXY Ahe/xw0pGuQE+hXrHvWdsYAPPtwpv1ufHhI78iKc4xac9Z7ro2DCCkoNG/OSaJ5eDmUL cJeUuKp5iQGHQmBcRZ0WXxxEXF9fjnjfNCW5VNIfyCxleZaz6rga+ZJNVo3FLMi5zLiM mpJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id; bh=mqmsKdmpmH18HuQQqA8F7CXlaVTzN1hPGjeY3SioQmM=; b=OyW5nlZXeCm1cY9wgg02hfiLVAW6DypDXwVYWLbD7FOngROHSeVRzjCYZrFyez7YXZ m3/TwGQuRdT4iy4LK1H226U/3Lc4u5mIlapQ3SzG2ybcCAs1yrO6neumVIuPeTS8RSpc ruk+DZPQRuXEH7r9EMS6qgXcN2o4RzdO0MGuVNWTm/2lCIJeG0VaI6sekGVKKJC5p14s a0UTuOr9cdDIK5HKWIe0tfjhls4LIVRRu1vSZzLgDIayXYgNlQkQWlRBcRHBqDgJ64Ag h69SyCUfKB8c5WrGDUbHTLGpvaf8KrMRyfhjHeghG6kV22dVcF38Ribqqs5M2UEAdnIp zf2Q== X-Gm-Message-State: AOUpUlFCSy/T9KzxKMCsI3GgAGseX9msouSWjysE/pdDLAy/AnfD/QAs 0uQlF1YWwajs8A+E6JT++GM= X-Google-Smtp-Source: AA+uWPzdUfxIxjvr359k7ZMeMhJ7F4ouhkfuKr8NFPglU+P+xL113awcwflDJXSbvQ5zS0UR5N8i6g== X-Received: by 2002:a63:f919:: with SMTP id h25-v6mr1102333pgi.401.1533707320892; Tue, 07 Aug 2018 22:48:40 -0700 (PDT) Received: from localhost (61-220-137-37.HINET-IP.hinet.net. [61.220.137.37]) by smtp.gmail.com with ESMTPSA id k125-v6sm3587600pgk.41.2018.08.07.22.48.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Aug 2018 22:48:39 -0700 (PDT) From: AceLan Kao To: Bjorn Helgaas , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] PCI: Fix calculation of bridge window's size Date: Wed, 8 Aug 2018 13:48:37 +0800 Message-Id: <20180808054837.19717-1-acelan.kao@canonical.com> X-Mailer: git-send-email 2.17.1 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 There are some 0 resource size pci devices, and it leads to the accumulator fails to maintain the correct value. It results in a strange issue on my machine that xhci_hcd failed to init. [ 2.437278] xhci_hcd 0000:05:00.0: init 0000:05:00.0 fail, -16 [ 2.437300] xhci_hcd: probe of 0000:05:00.0 failed with error -16 To fix this, check if the resource size equals to 0, doesn't increase size. Fixes: c9c75143a596 ("PCI: Fix calculation of bridge window's size and alignment") CC: stable@vger.kernel.org # 4.14+ Signed-off-by: AceLan Kao --- drivers/pci/setup-bus.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index 79b1824e83b4..ae05dde8c6e3 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c @@ -1061,7 +1061,8 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask, r->flags = 0; continue; } - size += max(r_size, align); + if (r_size != 0) + size += max(r_size, align); /* Exclude ranges with size > align from calculation of the alignment. */ if (r_size <= align)