From patchwork Wed Mar 19 18:54:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 3860241 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 B17139F369 for ; Wed, 19 Mar 2014 18:54:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D314B201F5 for ; Wed, 19 Mar 2014 18:54:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E8CF3201E7 for ; Wed, 19 Mar 2014 18:54:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753769AbaCSSyk (ORCPT ); Wed, 19 Mar 2014 14:54:40 -0400 Received: from mail-ie0-f174.google.com ([209.85.223.174]:39821 "EHLO mail-ie0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753707AbaCSSyi (ORCPT ); Wed, 19 Mar 2014 14:54:38 -0400 Received: by mail-ie0-f174.google.com with SMTP id rp18so9377935iec.33 for ; Wed, 19 Mar 2014 11:54:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=3bcnRldzbJv1HiC8v69t8uoeOKzzmUDn69AMBRdXaHE=; b=GhBn3jecIYGwqFFGHBc1EMgmPQaOIku03oaRhPtsRsucvpzSSPbe7Xvlih+1EVQeQ5 72wRxqs12XqFUKlKhbxv/L85BAeauCOB1TU8RCNA/99C1vuvYBwAjwtms+MZVRAirDBg ifYujtEue6FWhNnlZiJuy2jelzdX6+VM09LlF9OBqEUf2ysIAmv30CuabcIQea5S8mft mEEhmVJW0a5i/SDQo/IiYA4Pv+HgSJ7sm4r0g6atirY7u30eEERc+dGBBDAWvtFAMSPk gsXNZxLlU1Vw9r5k+9nYknfiwUWao6XgOXh3DBMamsPfjFse2IxPPl+3u9paeu/aW0g7 TZmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=3bcnRldzbJv1HiC8v69t8uoeOKzzmUDn69AMBRdXaHE=; b=XclZBUFHdI2FaIhH062gkAjIEOjx0TFA2TwGBzU8ffeTbaYj/eiOGtnq/RqHl+ihLi J/FhYY0Eo188gIbJ+v8QSIsC+u4DSQSYxiEWCUSBD8pirpajynWmkNqVIW9wHRLTz1T7 vlKsVED9nj5Nr6JU6g1fu7DgBvY07YbX7sT8EqDkT2yqiMsZQnE3hZEe6uhv6JaQ+LNG O4beMLuoqt6sjJFW17Ks2TOL+o9ef69aP6H/L3iXpDwdW+5G4RVWehuOz02QpEN8QNQO UHRSGYRAW4vrR30wn6CmkTXCtWYJx1BkrKUajlaG2dxh6WvYIeP7heasCXYCL0fhRd9u nqsQ== X-Gm-Message-State: ALoCoQlDglqhxAKgJsnj0AeJ/eAt8Fz+ZJ/NbRq7WWUw4TZD9TkDPCqDG5sY5m0etaTTKupG9aE1llSMgu5Bmza8OlGl0ZKFgzv3lwtpWlDBywPmoysdq59h17ldv5Qlxma2wkoRXWvSkLMgdBIbyOSesdI9V5h2beS6SFmyIBXfR4ZmJtfi630tF1rsHlvpN15Q4rtCPWCBiFYQ4U5ktWgED5sj5lM9Wm2XjC28QyzcIbLiofs43lo= X-Received: by 10.50.143.34 with SMTP id sb2mr16265635igb.11.1395255278273; Wed, 19 Mar 2014 11:54:38 -0700 (PDT) Received: from google.com (70-90-115-229-Denver.CO.hfc.comcastbusiness.net. [70.90.115.229]) by mx.google.com with ESMTPSA id v5sm43710985igb.0.2014.03.19.11.54.35 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 19 Mar 2014 11:54:37 -0700 (PDT) Date: Wed, 19 Mar 2014 12:54:23 -0600 From: Bjorn Helgaas To: linux-pci@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Ming Lei , Rusty Russell , Pekka Enberg , Sasha Levin Subject: Re: [PATCH 8/9] PCI: Ignore BAR contents when firmware left decoding disabled Message-ID: <20140319185423.GA5514@google.com> References: <20140226192614.10125.68711.stgit@bhelgaas-glaptop.roam.corp.google.com> <20140226193757.10125.81865.stgit@bhelgaas-glaptop.roam.corp.google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20140226193757.10125.81865.stgit@bhelgaas-glaptop.roam.corp.google.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD, 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 [+cc Ming, Rusty, Pekka, Sasha] On Wed, Feb 26, 2014 at 12:37:57PM -0700, Bjorn Helgaas wrote: > Don't rely on BAR contents when the command register says the BAR is > disabled. > > If we receive a PCI device from firmware (or a hot-added device that was > just powered up) with the MEMORY or IO enable bits in the PCI command > register cleared, there's no reason to believe the BARs contain valid > addresses. > > In that case, we still know the type and size of the BAR, but this > patch marks the resource as "unset" so we have a chance to reassign it. > > Historically, we often used "BAR == 0" to decide the BAR is invalid. But 0 > is a legal BAR value, especially if the host bridge translates addresses, > so I think it's better to decide based on the PCI command register, and > store the conclusion in the IORESOURCE_UNSET bit. I plan to replace this patch with the following, which only sets IORESOURCE_UNSET when we already have been clearing the bus region start address. (This probably should have been a separate patch to begin with, mea culpa.) This is intended for the v3.15 merge window, so I made the minimal change to reduce risk. Thanks to Ming Lei for prompting me to look at this; I think the issue he reported with the original patch is really a problem somewhere else that the patch just happened to expose, but the original patch was more aggressive than necessary, so this revision tones it down a bit. Bjorn PCI: Mark 64-bit resource as IORESOURCE_UNSET if we only support 32-bit From: Bjorn Helgaas If we don't support 64-bit addresses, i.e., CONFIG_PHYS_ADDR_T_64BIT is not set, we can't deal with BARs above 4GB. In this case we already pretend the BAR contained zero; this patch also sets IORESOURCE_UNSET so we can try to reallocate it later. I don't think this is exactly correct: what we care about here are *bus* addresses, not CPU addresses, so the tests of sizeof(resource_size_t) probably should be on sizeof(dma_addr_t) instead. But this is what's been in -next, so we'll fix that later. Signed-off-by: Bjorn Helgaas --- drivers/pci/probe.c | 1 + 1 file changed, 1 insertion(+) -- 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 6e34498ec9f0..78335efbbb74 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -252,6 +252,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type, /* Address above 32-bit boundary; disable the BAR */ pci_write_config_dword(dev, pos, 0); pci_write_config_dword(dev, pos + 4, 0); + res->flags |= IORESOURCE_UNSET; region.start = 0; region.end = sz64; bar_disabled = true;