From patchwork Sat Oct 13 00:49:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changbin Du X-Patchwork-Id: 10639785 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-2.web.codeaurora.org (Postfix) with ESMTP id 9BDC617E1 for ; Sat, 13 Oct 2018 00:51:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9192B2B6BE for ; Sat, 13 Oct 2018 00:51:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7F38F2B6E2; Sat, 13 Oct 2018 00:51:25 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 2C00B2B6BE for ; Sat, 13 Oct 2018 00:51:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726273AbeJMI0X (ORCPT ); Sat, 13 Oct 2018 04:26:23 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:40254 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726200AbeJMI0X (ORCPT ); Sat, 13 Oct 2018 04:26:23 -0400 Received: by mail-pf1-f193.google.com with SMTP id s5-v6so6976031pfj.7; Fri, 12 Oct 2018 17:51:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=+rQhsJQbQUL7ExRr7DE8fPI8d4Z8EwKvAeWUvzAs9A4=; b=TmYc7WyamW4GgykUyyigNA1WeUGtu+jzSL+hGSJop2DdvkXOjBq0JNnk4GvnpphnD7 bu7DwavRqeXh1tEb7Pij4fH88dlZdVgI3IW8rz4YrDJ9+5w4OFhf1gxhtP7tuxI0mfM7 umqwc4XASe3+hjmf7yxkWBIfZ/0VRCXpLeUCGBQdxhDjEgDbzvfefNraFCndJQGJvSoN E83H0sjCQUqkEa2tDWiK+6j1UOEpiyAtZmXMTC0tinRin1uDLoUefcF+uvQU5nlfk3w2 JzpefTyJN276KwMlaZ+7BjZQ2g2+wwB1GHcNjB3RL0fOreJhh21dcx/AelYZzDAGHkEt cZwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=+rQhsJQbQUL7ExRr7DE8fPI8d4Z8EwKvAeWUvzAs9A4=; b=dtbRuo2Ufm7b9vZ9YQKKy2hyrrvtjom/87RbH1pIPzTl9wLAKZ7Cb14YxZkSlDwhol VCOsL8sXtJRosHd1VTPI4PYmoSdxzAxQstNjGpxvFGlORszGhzOVZgvqR1T5Q9gQsV3A mzlAgakFuwMjTr/8ZjweMrfhXAGNC3PjHVqxixvLlkJM1Kf5fqZj2aeNvERkKCnbRRAV zbHsvgkenySnyetwsngVKiy07I48j/HEnhz5mlQVFZx5b7nEXla/VO0GBZa5Zc40pg7f 8tFMuJ6e5/GCdXkMb3cMzVowhJkcaoAgs/KBMnZ3xTUT/HrgKE8u8La46MWyed0aETjF cTxw== X-Gm-Message-State: ABuFfohvDG89YMmrWxaSsyr3PyppFDnt/DrZ2OhMKXi8xtlSKzGqQHDs 08VDqO2CByaPuBGHgHuzWYsdoeBG2Uqo3g== X-Google-Smtp-Source: ACcGV60qsofhhKlSDV0yARQTfrTssB9XLdKd6V3ZgcPMwJiLAIb2FEtwjhrC373S3YjZS+SLtUhY6g== X-Received: by 2002:a62:4bd2:: with SMTP id d79-v6mr8246315pfj.38.1539391883114; Fri, 12 Oct 2018 17:51:23 -0700 (PDT) Received: from localhost.localdomain ([218.108.98.82]) by smtp.gmail.com with ESMTPSA id b62-v6sm6773107pfa.159.2018.10.12.17.51.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Oct 2018 17:51:22 -0700 (PDT) From: changbin.du@gmail.com To: bhelgaas@google.com Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Du Changbin Subject: [PATCH] PCI: make pci_size() return real size Date: Sat, 13 Oct 2018 08:49:19 +0800 Message-Id: <20181013004919.3202-1-changbin.du@gmail.com> X-Mailer: git-send-email 2.17.1 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 From: Du Changbin Currently, the pci_size() function actually return 'size-1'. Make it return real size to avoid confusing. Signed-off-by: Du Changbin --- drivers/pci/probe.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 201f9e5ff55c..8ff2b1413865 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -121,13 +121,13 @@ static u64 pci_size(u64 base, u64 maxbase, u64 mask) * Get the lowest of them to find the decode size, and from that * the extent. */ - size = (size & ~(size-1)) - 1; + size = size & ~(size-1); /* * base == maxbase can be valid only if the BAR has already been * programmed with all 1s. */ - if (base == maxbase && ((base | size) & mask) != mask) + if (base == maxbase && ((base | (size - 1)) & mask) != mask) return 0; return size; @@ -278,7 +278,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type, /* Above 32-bit boundary; try to reallocate */ res->flags |= IORESOURCE_UNSET; res->start = 0; - res->end = sz64; + res->end = sz64 - 1; pci_info(dev, "reg 0x%x: can't handle BAR above 4GB (bus address %#010llx)\n", pos, (unsigned long long)l64); goto out; @@ -286,7 +286,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type, } region.start = l64; - region.end = l64 + sz64; + region.end = l64 + sz64 - 1; pcibios_bus_to_resource(dev->bus, res, ®ion); pcibios_resource_to_bus(dev->bus, &inverted_region, res);