From patchwork Tue Mar 11 17:42:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 3813601 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 EB5799F1CD for ; Tue, 11 Mar 2014 17:44:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CDC432020E for ; Tue, 11 Mar 2014 17:44:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 02EB0201DD for ; Tue, 11 Mar 2014 17:44:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755208AbaCKRnC (ORCPT ); Tue, 11 Mar 2014 13:43:02 -0400 Received: from mail-ie0-f170.google.com ([209.85.223.170]:44303 "EHLO mail-ie0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755205AbaCKRnA (ORCPT ); Tue, 11 Mar 2014 13:43:00 -0400 Received: by mail-ie0-f170.google.com with SMTP id rd18so9350935iec.29 for ; Tue, 11 Mar 2014 10:43:00 -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=ZtPsPOUnxzeB3Cofgtz3E7rCXcMCaYRLomCBQ0VCsYE=; b=R5fNmj6rM+cy9nXXVAap0woDDEfkoD/jo67CYuWBNXl33p8smI+VrdfKoz2VQ7WOjU /DpKy1Sgg+JnEzYg0NC8F6A8siN0KbWfD7kYhDiRkbefPrguUDJJazXtTvCi763dWvn+ VQbXGWMTfHxSevifLNSuPdWYGzzWrK/5OnW8bSUgrWIAkgU3HPVrIu/tXbvUeRLFFCX8 s2xyidNlmNkQNp/g3QVyRpX7aYV4AHfiVg3eMwveuk9k51koi+T+jbnw869nuW25xaGI u2uXSLJ+WLa67LLioArkILUFceO3GKjgQqxFWL8tNDlKlgQpEM+Vpiuc2ylQ45D4V/U8 nDWg== 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=ZtPsPOUnxzeB3Cofgtz3E7rCXcMCaYRLomCBQ0VCsYE=; b=RHbOhefbqKpk4AzaT+jZhUOxzmQ4IJD+vd4Ara5OhY0LXYp0CvpyYzlf46FnMhGxxL PL2oA/dC2M1jWM50E9K0X6p65c80Fb1jyngQKdMmnc4tPq9D/HbxBHsCNdsUCsqzIvMa d11WCBGphAf0T+H8tFrSQVLqSIEtaLjktCYUpCi5eOtnqGmJdk7RkIZZHvseO59kuJ/O Z8FkKxhKw6+NXjWNZ/L6mkJjCbqMqnQnq5OXGIpVWENiUf9YOUAnUPT2O/G1P5Sq1u3I toRoSzIrZPbcO3KVBqM+zCQHLH3h0zzK0kguhbUDBph8s7hM/Li7+MRe2RK9XNzuxUBV UShA== X-Gm-Message-State: ALoCoQlIkKydxBqA2SYLtmOmS3VbNLGxMp2zRnnm1pG6fq60s672KeLFX3zWdJmrLaSAcsqtwYB+YBS4NgOt34YqHQ5F7eWrAANnl9jXbzyh915BXNc/m5Swb9WMQGl7AYcQxUDvI8+sSpJ4irUc2fZh5XuVDi0hUOAd1bu7QVc5VJ2II8dIXgzTXr6idcf4WQov+VIZ2GcagwOTpXQOhDbqXt2NhdvwRZfnLfK+P4DsUXzxq2eHzYs= X-Received: by 10.50.62.211 with SMTP id a19mr24903197igs.46.1394559780208; Tue, 11 Mar 2014 10:43:00 -0700 (PDT) Received: from localhost ([172.16.50.109]) by mx.google.com with ESMTPSA id w9sm49657226iga.10.2014.03.11.10.42.59 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 11 Mar 2014 10:42:59 -0700 (PDT) Subject: [PATCH 3/5] PCI: Check all IORESOURCE_TYPE_BITS in pci_bus_alloc_from_region() To: linux-pci@vger.kernel.org From: Bjorn Helgaas Cc: Paul Bolle , Yinghai Lu , linux-kernel@vger.kernel.org Date: Tue, 11 Mar 2014 11:42:57 -0600 Message-ID: <20140311174257.23084.80235.stgit@bhelgaas-glaptop.roam.corp.google.com> In-Reply-To: <20140311173556.23084.57635.stgit@bhelgaas-glaptop.roam.corp.google.com> References: <20140311173556.23084.57635.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=-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 When allocating space from a bus resource, i.e., from apertures leading to this bus, make sure the entire resource type matches. The previous code assumed the IORESOURCE_TYPE_BITS field was a bitmask with only a single bit set, but this is not true. IORESOURCE_TYPE_BITS is really an enumeration, and we have to check all the bits. See 72dcb1197228 ("resources: Add register address resource type"). No functional change. If we used this path for allocating IRQs, DMA channels, or bus numbers, this would fix a bug because those types are indistinguishable when masked by IORESOURCE_IO | IORESOURCE_MEM. But we don't, so this shouldn't make any difference. Signed-off-by: Bjorn Helgaas --- drivers/pci/bus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 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/bus.c b/drivers/pci/bus.c index 38901665c770..e3bdc88668ec 100644 --- a/drivers/pci/bus.c +++ b/drivers/pci/bus.c @@ -144,7 +144,7 @@ static int pci_bus_alloc_from_region(struct pci_bus *bus, struct resource *res, struct resource *r, avail; resource_size_t max; - type_mask |= IORESOURCE_IO | IORESOURCE_MEM; + type_mask |= IORESOURCE_TYPE_BITS; pci_bus_for_each_resource(bus, r, i) { if (!r)