From patchwork Sat Aug 5 06:37:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yinghai Lu X-Patchwork-Id: 9882919 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 18D10602B6 for ; Sat, 5 Aug 2017 06:41:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F3FAF288C7 for ; Sat, 5 Aug 2017 06:41:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E6B7F288C9; Sat, 5 Aug 2017 06:41:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 87F8E27CEA for ; Sat, 5 Aug 2017 06:41:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752540AbdHEGks (ORCPT ); Sat, 5 Aug 2017 02:40:48 -0400 Received: from mail-pg0-f67.google.com ([74.125.83.67]:37806 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751241AbdHEGi1 (ORCPT ); Sat, 5 Aug 2017 02:38:27 -0400 Received: by mail-pg0-f67.google.com with SMTP id 83so3663477pgb.4; Fri, 04 Aug 2017 23:38:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=k1iEaLsJMUIvuZmrl2PdZsI593gfU23XbddEBW8tu0U=; b=jTCbB/z479eMrE4KeBEcU4HxX65B2PqyPzWyVq9FycLuGfmYxVJAIH7fYrEkB7ozrV 4jkw9PKwqFWbGp2sI+mnpJlrm99FOquBK/95XgBk2c7p+mtRO6cEQbMYhjcHtD5v6I0c 1B3rnaCFbxezsEfaGFuKggJM3wWGpQHMfvtY6ltKhVzvSerKjITgHpW1IeSKv4fMq7yw dWt2EH3CjIaQzIjRoDprAFATZ1okPuL3Ol8EkFhUU81EJ7my9nqSZXO7Tav5mdwMNttA 1wz+5hVtEtf1SeKJnbfUlI/W9/tvohvmdP2ZT8o8cOSeL16Xq3sKSRuPtuijV1QkLMOW Y3HA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=k1iEaLsJMUIvuZmrl2PdZsI593gfU23XbddEBW8tu0U=; b=g/qrma32gfubxAK3uYRVRv5UZQ1TG5IUnGfaVPgCyzYTQXWN3fFL32HKHp3WFT/nUE 5vr/VdouT2NqBTH1xC47un6FtzxOw9+WIPhX4hq/TjqzkirACbEfePLeSb4Yq1gat1VV ZfjbvWsOfAXn57LAb1uyvYbqZwYTCRor/62cmpA8LFf4yGtx1mQ0AX0yVtH8rzZgw4yw HIESDtCWsnM68D6ejpTns2kxt+mbxrOJFsi/fzmOO6Red7TaBEnBnAVJrR3UZcxGYUTu 77USleEGoin7teRxxc/NF6HVOPzXnYvUKDQ8BE+GaAcllAvXCv2MmdaK5cHRC5ArgQTx 8WVQ== X-Gm-Message-State: AIVw111QVCi6xQMMMorv/AwjZ20NJ1NWXKgLfAhFCgLx/GzKMo0iCcX9 jSWu8Wx6fcimCZ3kaqI= X-Received: by 10.98.16.154 with SMTP id 26mr4961241pfq.58.1501915106579; Fri, 04 Aug 2017 23:38:26 -0700 (PDT) Received: from dhcp-whq-twvpn-3-vpnpool-10-159-238-106.vpn.oracle.com (c-69-181-250-163.hsd1.ca.comcast.net. [69.181.250.163]) by smtp.gmail.com with ESMTPSA id j124sm6131387pfc.78.2017.08.04.23.38.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 Aug 2017 23:38:26 -0700 (PDT) From: Yinghai Lu To: Bjorn Helgaas Cc: Linus Torvalds , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Yinghai Lu Subject: [PATCH 01/10] PCI: avoid arch_remove_reservations() for PCI_TEST Date: Fri, 4 Aug 2017 23:37:52 -0700 Message-Id: <20170805063801.15880-2-yinghai@kernel.org> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170805063801.15880-1-yinghai@kernel.org> References: <20170805063801.15880-1-yinghai@kernel.org> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP arch_remove_reservations will clip out with e820 from host that kernel running, that will cause failure from PCI_TEST from simulated data. PCI_TEST has different iomem resource instead iomem_resource, so check if iomem_resource is related to avoid calling arch_remove_reservations() Signed-off-by: Yinghai Lu --- arch/x86/kernel/resource.c | 15 +++++++++++++-- include/linux/ioport.h | 3 ++- kernel/resource.c | 5 +++-- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/arch/x86/kernel/resource.c b/arch/x86/kernel/resource.c index 5ab3895..f19b0f6 100644 --- a/arch/x86/kernel/resource.c +++ b/arch/x86/kernel/resource.c @@ -35,14 +35,25 @@ static void remove_e820_regions(struct resource *avail) } } -void arch_remove_reservations(struct resource *avail) +static int is_from_iomem_resource(struct resource *root) +{ + while (root->parent) + root = root->parent; + + if (root == &iomem_resource) + return 1; + + return 0; +} + +void arch_remove_reservations(struct resource *root, struct resource *avail) { /* * Trim out BIOS area (high 2MB) and E820 regions. We do not remove * the low 1MB unconditionally, as this area is needed for some ISA * cards requiring a memory range, e.g. the i82365 PCMCIA controller. */ - if (avail->flags & IORESOURCE_MEM) { + if ((avail->flags & IORESOURCE_MEM) && is_from_iomem_resource(root)) { resource_clip(avail, BIOS_ROM_BASE, BIOS_ROM_END); remove_e820_regions(avail); diff --git a/include/linux/ioport.h b/include/linux/ioport.h index 6230064..4e9272d 100644 --- a/include/linux/ioport.h +++ b/include/linux/ioport.h @@ -177,7 +177,8 @@ extern struct resource *insert_resource_conflict(struct resource *parent, struct extern int insert_resource(struct resource *parent, struct resource *new); extern void insert_resource_expand_to_fit(struct resource *root, struct resource *new); extern int remove_resource(struct resource *old); -extern void arch_remove_reservations(struct resource *avail); +extern void arch_remove_reservations(struct resource *root, + struct resource *avail); extern int allocate_resource(struct resource *root, struct resource *new, resource_size_t size, resource_size_t min, resource_size_t max, resource_size_t align, diff --git a/kernel/resource.c b/kernel/resource.c index 9b5f044..4174020 100644 --- a/kernel/resource.c +++ b/kernel/resource.c @@ -570,7 +570,8 @@ int region_intersects(resource_size_t start, size_t size, unsigned long flags, } EXPORT_SYMBOL_GPL(region_intersects); -void __weak arch_remove_reservations(struct resource *avail) +void __weak arch_remove_reservations(struct resource *root, + struct resource *avail) { } @@ -622,7 +623,7 @@ static int __find_resource(struct resource *root, struct resource *old, goto next; resource_clip(&tmp, constraint->min, constraint->max); - arch_remove_reservations(&tmp); + arch_remove_reservations(root, &tmp); /* Check for overflow after ALIGN() */ avail.start = ALIGN(tmp.start, constraint->align);