Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1675898imm; Wed, 8 Aug 2018 23:31:33 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxGvBNvJ161tXK8sjjeGRfiiLbAu/Bqn8Yc5BBVnlA5H9uA7R2+LLT+3oXGe7Z7BetL9rUr X-Received: by 2002:a63:c114:: with SMTP id w20-v6mr847231pgf.234.1533796293045; Wed, 08 Aug 2018 23:31:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533796293; cv=none; d=google.com; s=arc-20160816; b=W5dQA0Hs8yt3jRM7eUCzBF9HxfDexgHdaaviUdnuHC2NNaAtGYgkUu9RG0Hm//fEqH bFbe06+ivQpoGiqC5qFIW5fNvo8iu5JDjUm+PzS3A5ZeoqqtbdEv/+cOqv4ejcW1/7d+ Ggu/A2lNQQZQFgdm8BLNCn2bXF+adfhDrDcTrpuJh/rw0dXbtIp6il/tKD7QG9ufTkvj F5CYfLYufMv1Z4hxEWS2RUm8/KxbOOnvhYKKrLFQTFf1mrSVwkeDhELa5TY6a004BRbe q51mALwcSwPwydjTp/k+k2VSZacYKlooACNTtAobO+da6c/ratwso4cqtvIEfI/RX0R6 rRRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:arc-authentication-results; bh=UksJvPBvsxySK/XZfsJaYOi5Y+WXgAxVtElUTL7ZzGY=; b=Z8L+5o0pC/w2shHsdOXNlrvjN4ZUGxxS4WCYaFmYLFOfVfDcVL9XoPB99wl6lY2ur8 jKdFPHOKuBCKCsQ9Mw6UQ9muZg0QffTkiyPcrSmg6+mIQgLNDSRgqWUTobCE77OOJRjv v7dv/U+Ia7fpY7CkKEQki9M4BcGC2+yX3xDrnU8RCqj/H4Y0pabgxQNgkiI5XgZwWFb4 3qoh322ghjhOxnl26fcDqcML0p1q7ipfEnkDs7HZR54QWEnxomteaany/MIKtQLocS6E dU1anYORoj3Sd6FVwi3D7PPdAQQ0JEgGDm+vo5ip2eHRz0qCtNshTyQQyt31j5qEEImD 4Pgg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l184-v6si6055397pge.257.2018.08.08.23.31.18; Wed, 08 Aug 2018 23:31:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728062AbeHIIww (ORCPT + 99 others); Thu, 9 Aug 2018 04:52:52 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:45433 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727614AbeHIIww (ORCPT ); Thu, 9 Aug 2018 04:52:52 -0400 Received: from mail-wr1-f71.google.com ([209.85.221.71]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1fneRw-0000CA-Gm for linux-kernel@vger.kernel.org; Thu, 09 Aug 2018 06:29:32 +0000 Received: by mail-wr1-f71.google.com with SMTP id z13-v6so3862733wrq.3 for ; Wed, 08 Aug 2018 23:29:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=UksJvPBvsxySK/XZfsJaYOi5Y+WXgAxVtElUTL7ZzGY=; b=Mo3hEX8v0WsLM3i5wfYirFL2CIo8wgs5xgmb+XPukej5WU3ElXF21GWDBNvveyZIy5 bVkJzBLuD4UlbNtleDzArE7BIxCwulNWuj/UctIysiBPRdyCYaqe0WoCzVkRZs39aPC8 MdPvn4DRbPY7eRNbGfgIf5MjzM1+l1RPZxqtwUJLB+oFGFKxY6Qb031FPthWRLqC7dYZ r4a1xZ6T6bJQXW/sUUpLn7PE7nrTxZia/B5xF4TQxtWkvkQENAyiQ/l8TanrUoCrehB1 Y0dk9MgpeLNnNsX+QyHuXI3RYX2PlO8H04byQeGd8kD31gPbMG14CHGW00c3t6l0ISx9 3J/Q== X-Gm-Message-State: AOUpUlHz1vMgeLbBzr3jwQZodBFKf3tq1LqB6pbkzwD8AykjgmwIKTKW I+1HUZDpC01Zv3Mk08fg3oKUMq1YXO64IBRgiQsWvxdJiKHhg1vPYWPcIgEIjoAsqV0jS5kt/LN 2ZAC4wjXRocpZjHDeSCN9Xj3k7t4VQg7pSfGG3AlJ1zA+vJtGZKInBukQcA== X-Received: by 2002:a1c:ca0f:: with SMTP id a15-v6mr650635wmg.102.1533796172205; Wed, 08 Aug 2018 23:29:32 -0700 (PDT) X-Received: by 2002:a1c:ca0f:: with SMTP id a15-v6mr650631wmg.102.1533796171945; Wed, 08 Aug 2018 23:29:31 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a1c:4e18:0:0:0:0:0 with HTTP; Wed, 8 Aug 2018 23:29:31 -0700 (PDT) In-Reply-To: <20180808180019.GE49411@bhelgaas-glaptop.roam.corp.google.com> References: <20180808054837.19717-1-acelan.kao@canonical.com> <20180808180019.GE49411@bhelgaas-glaptop.roam.corp.google.com> From: AceLan Kao Date: Thu, 9 Aug 2018 14:29:31 +0800 Message-ID: Subject: Re: [PATCH] PCI: Fix calculation of bridge window's size To: Bjorn Helgaas Cc: Bjorn Helgaas , linux-pci@vger.kernel.org, "Linux-Kernel@Vger. Kernel. Org" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Bjorn, Here is the public bug. https://bugzilla.kernel.org/show_bug.cgi?id=200769 Best regards, AceLan Kao. 2018-08-09 2:00 GMT+08:00 Bjorn Helgaas : > On Wed, Aug 08, 2018 at 01:48:37PM +0800, AceLan Kao wrote: >> 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 > > I don't think it's possible for a PCI device to have a BAR of zero > size. Bits 0-3 of memory BARs are read-only, leading to a minimum BAR > size of 16 bytes; similarly, bits 0-1 of I/O BARs are read-only, > giving a minimum size of 4 ports. > > My guess is that if you have a pci_dev with a resource that looks like > it's valid but has zero size, that resource came from OF or device > tree. If that's the case, I'd say we should fix the OF or DT parsing > code to reject those resources. If we do that, we shouldn't need the > patch below. > > Can you open a bugzilla.kernel.org report and attach the complete > dmesg log leading up to this, as well as the "sudo lspci -vv" output > for this device? It should have clues about how we got here. > >> 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) >> -- >> 2.17.1 >>