From patchwork Wed Apr 30 01:00:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 4089991 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id BCDD99F39D for ; Wed, 30 Apr 2014 01:00:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E56FF2011E for ; Wed, 30 Apr 2014 01:00:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 25B7120200 for ; Wed, 30 Apr 2014 01:00:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755713AbaD3BAK (ORCPT ); Tue, 29 Apr 2014 21:00:10 -0400 Received: from mail-ig0-f181.google.com ([209.85.213.181]:60087 "EHLO mail-ig0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755497AbaD3BAI (ORCPT ); Tue, 29 Apr 2014 21:00:08 -0400 Received: by mail-ig0-f181.google.com with SMTP id h18so1124599igc.14 for ; Tue, 29 Apr 2014 18:00:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=subject:to:from:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-type:content-transfer-encoding; bh=GQdpTNcZ2Jh7tld3yiOXMmAj/fGo8kNHMDHkyqBzkL8=; b=PiTP460i3loOgY4+99TvDhz+ws6xTV2GIPid/d+IPIov2Vcd19uTURzeUgQfFA0Nx4 e8wnSiEhxK2FbdA6xHQXZqtLvxOw5t22mlVmOUsxrUTjxHN6iRWpyCKppVPRKQTB+IGO suKofuBRnjVpQ79oUgo7nDG2bif6JgHyhnWNfYfnA4bOLsdMJQpd2lSV00WgiG/n1iI2 4Yq5+RTGNb2Xoa+bilEWvtMflUZuw4iSQdeqW75UGTGe2yeSxRWLzGidnGRbZeGTmY2v hJflHLIYTo1LFV2X0lEr/cZU7GX0n3i0ogizRKG9HUaf8cJa3n0DEHzCJQzz+PiUn4gp x/VA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:from:cc:date:message-id:in-reply-to :references:user-agent:mime-version:content-type :content-transfer-encoding; bh=GQdpTNcZ2Jh7tld3yiOXMmAj/fGo8kNHMDHkyqBzkL8=; b=GAP2PwoWfKijZh6KyaWLgZluBRTEeahWN/JXhx2KuOB6U1eLY4dRUz6TSr8yigfy3I PEsoLWyewRNtqOn5DmeXjgUYtlP7T6IyTG6A6fPQtOitXWFNJOir8cxodXE/Uz7vD987 eqlCyCJ0v67fVZgMSJEypGR41M2or4EwHUW7zAaIvKKCWb0hSykAIFRBRQqPwDysj5iR QivbtlqkWgp5qJtUkHlY0KBsgTv0jbugWcz8KuzkvCBk99uEe0cFR56eXv9/JfSqKPRT KQ3I9IdPOkpFEZjtVEoAQqngU3fp9d7UbRoZUcM4or23swh9VMMROAtf/IcQ8VoBYkw0 sPbQ== X-Gm-Message-State: ALoCoQnWKp+E78jM/uMa0Z2bz4XFABLIDCsvf8rZuWQh3mWMgysnZPx2PDmrHC4Nos3PFE0ujeyoEt/hgxzopJLo8txnEZCwB9YivzcqXBakHdPXlJEdgEo6EGrvwEGSslfdqCrXAROt09v/RBkBAcAzn2Kxyw8xmWtw12pkTR5pikL6w84aP3PzWoTfimI9KEtY+SmxqhhalxCwrveuoalDPed+M6ad60N33qay5+vF9zDh1XXRu+U= X-Received: by 10.50.85.18 with SMTP id d18mr1230961igz.42.1398819607212; Tue, 29 Apr 2014 18:00:07 -0700 (PDT) Received: from localhost ([172.16.51.53]) by mx.google.com with ESMTPSA id vu3sm96309igc.6.2014.04.29.18.00.06 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 29 Apr 2014 18:00:06 -0700 (PDT) Subject: [PATCH 4/7] PCI: Don't set BAR to zero if dma_addr_t is too small To: linux-pci@vger.kernel.org From: Bjorn Helgaas Cc: linux-kernel@vger.kernel.org Date: Tue, 29 Apr 2014 19:00:05 -0600 Message-ID: <20140430010005.13138.18200.stgit@bhelgaas-glaptop.roam.corp.google.com> In-Reply-To: <20140430005642.13138.99577.stgit@bhelgaas-glaptop.roam.corp.google.com> References: <20140430005642.13138.99577.stgit@bhelgaas-glaptop.roam.corp.google.com> User-Agent: StGit/0.16 MIME-Version: 1.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If a BAR is above 4GB and our dma_addr_t is too small, don't clear the BAR to zero: that doesn't disable the BAR, and it makes it more likely that the BAR will conflict with things if we turn on the memory enable bit (as we will at "out:" if the BIOS left it enabled). We should also print the BAR info and its original size so we can see what happens when we try to assign space to it. Signed-off-by: Bjorn Helgaas --- drivers/pci/probe.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 82cd75f6118a..dd710b12d34c 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -174,7 +174,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type, u64 l64, sz64, mask64; u16 orig_cmd; struct pci_bus_region region, inverted_region; - bool bar_too_big = false, bar_disabled = false; + bool bar_too_big = false, bar_too_high = false; mask = type ? PCI_ROM_ADDRESS_MASK : ~0; @@ -254,13 +254,11 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type, } if ((sizeof(dma_addr_t) < 8) && l) { - /* Address above 32-bit boundary; disable the BAR */ - pci_write_config_dword(dev, pos, 0); - pci_write_config_dword(dev, pos + 4, 0); + /* Above 32-bit boundary; try to reallocate */ res->flags |= IORESOURCE_UNSET; res->start = 0; res->end = sz64; - bar_disabled = true; + bar_too_high = true; goto out; } else { region.start = l64; @@ -311,7 +309,10 @@ out: if (bar_too_big) dev_err(&dev->dev, "reg 0x%x: can't handle BAR larger than 4GB (size %#010llx)\n", pos, (unsigned long long) sz64); - if (res->flags && !bar_disabled) + if (bar_too_high) + dev_info(&dev->dev, "reg 0x%x: can't handle BAR above 4G (bus address %#010llx)\n", + pos, (unsigned long long) l64); + if (res->flags) dev_printk(KERN_DEBUG, &dev->dev, "reg 0x%x: %pR\n", pos, res); return (res->flags & IORESOURCE_MEM_64) ? 1 : 0;