Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1117099imm; Wed, 8 Aug 2018 11:02:13 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxSexUL9yqlVsGws8H4QbLRyFhZPZMsmDV9b4+UkP5ml2/SRbnIV3ROM2cE7u9ok1mhoTja X-Received: by 2002:a65:448a:: with SMTP id l10-v6mr3536551pgq.382.1533751333255; Wed, 08 Aug 2018 11:02:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533751333; cv=none; d=google.com; s=arc-20160816; b=EQuUsuY4pb0OYfh+1ul+V80GD6s/tKTt65G5z4K6zLvjz5FkpRyLnffZ3rfgQQyA11 MI/TRaWrqWPOOGDMkAq0IqJdEkI95ib/sSY4J7JZDgC7hX6fvtKp13btY/9x+sBtX8Za Xz49bNN83SBpRhtxCFtjtl9be1EhSgHfWqDzj2V4cAhlCDq6vBSiG44kxg4G/qGMBugn cAZvLBuxbewGcF8v+uUiiyTR3IfVIhzfiggxM3tmJloodx2xIj2lD1z34Eff0mQbV3lv itE0+BOKutlgb+RtEq2C3YdDwyOpa1lGzxkXqisjaCRddeUSVrrgOU/I+rgMWTGv2uVY P4ZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=nmQFMG41w3RV2E8uaLgg6XHG/kVpAM62vVT4F8YOBAw=; b=Toc8BW9+rXhV8Sy1FKKO0WigzBnChOezUsQAeITgXVYrmcV7OmOWW0nvMSG4GVWIA8 ktBn0HquhKPzuxBKT+GUZmajvXNzIVPpc/yCmTmVt2Wmpw+GABVokbIj2gp5ff294V34 wq6exrpBbFegz6xsj9wpjpBVOvKTYMzVGMSfWfLcsV/8/5AU5bfQxUOUJ9fkwdeTv7Q6 fGQog3m388ImdHcwQ5b/2XdcUefleZXX+e0szHuCBqnrxtjuiT9X5ZAZgasMPmE/HBDK KKSxiHN5uXcyvJBVfx6W1ElLKu+A7nebC2lUEEo16CMmnF9QODegxd+vCuiTHy188PDn VGkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OZJWm+UE; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q1-v6si5109638pgr.68.2018.08.08.11.01.58; Wed, 08 Aug 2018 11:02:13 -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; dkim=pass header.i=@kernel.org header.s=default header.b=OZJWm+UE; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730129AbeHHUVJ (ORCPT + 99 others); Wed, 8 Aug 2018 16:21:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:48260 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727748AbeHHUVI (ORCPT ); Wed, 8 Aug 2018 16:21:08 -0400 Received: from localhost (unknown [69.71.4.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CBAE02178B; Wed, 8 Aug 2018 18:00:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1533751221; bh=Wksg3JBMPSQrV6GbShuhwdXUasvykInLpj5HgayMF/c=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=OZJWm+UEijUripPhh8rFZzD3NHXCHm8wZ+wn2J+1V8tX1icfhLQXYIUC9CWYoKi8U hwQryoB1jywLdJIzaDpYwI4G6Emrkjkw9XX71vjGJbmZ5d9QzRzIsd4WluNkTuIFgQ W6R7nqPZXk05J6gahSiIyAFcvOHJTv5Esjz7KmN0= Date: Wed, 8 Aug 2018 13:00:19 -0500 From: Bjorn Helgaas To: AceLan Kao Cc: Bjorn Helgaas , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] PCI: Fix calculation of bridge window's size Message-ID: <20180808180019.GE49411@bhelgaas-glaptop.roam.corp.google.com> References: <20180808054837.19717-1-acelan.kao@canonical.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180808054837.19717-1-acelan.kao@canonical.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 >