Received: by 10.223.176.5 with SMTP id f5csp1850192wra; Thu, 8 Feb 2018 04:37:26 -0800 (PST) X-Google-Smtp-Source: AH8x224mJqVPfOFWnQMEZUMaRp5iaJ/oEq0gluCjvBs+f7jY1kakvtWGDTwwNa2RGjiooQ4YAPvw X-Received: by 10.99.112.23 with SMTP id l23mr417080pgc.243.1518093446598; Thu, 08 Feb 2018 04:37:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518093446; cv=none; d=google.com; s=arc-20160816; b=B2C7krGbySnH1UIlkiE4pSh6rXEbZhFUOgW9kds/9bGKKL+YZZCNQLXBSCxtusJvZt txu9adsLB/H6q4JpF/VtvraYxzJXIrpoMlX/5FZIrlJdLF9sYxmzwWqgTyZ+8OlEed77 6KIuW1B7eSvLvxr/O0izw3xRPE+ndrlxlBdLkPC3LnvfRSEkaUrJmxhy3y/DoMDMg7JC AgStS6QnhnI07ksQsCfDo8WS+5GYBOnYopTF2Ak/u5HFCcqAYfZvtB5DdRbzyC8XkTP+ a/JVvlb/XoIbMnBYJ5nyft59ez2au7xeBIM+Khin80hXvYP9ufXFvHkHL4qvun/O+fte g4Ig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=sPNQqtjWVTIiu5lp1Lwlen5Oz5gVFsPFgnq3WfVEE2w=; b=SYqZXc+arv3zShBlHaYPK/FidpMI/HPirAm3WXymJrdSFVJR5LvzO/kNA6HHTnFJt4 xAmtZJ+VvT9Zz3eWzUcDr+eIQ3kVgdRf9sMt3/jldzEQF3UbD7Uc8RQdOe2aIF6cy6bk UqaeMpPIma5XVCbnP5kjrlUOdexvX8xug7rHdWQBpkV1W5I6qC/GA4utP3TbM8iFvVJU yn9kDuN6ZBMVj7TmxSIxWOjELySb58dQySVxIUKBDHWXSyvoaeS1XlcFX3aWDfPJBxsq bFXMA/W/pXwWD5Cfc3Ivehf9/9pljKRPdq5M9wabRBZ1GP1rii8pjdxorjb1Bwa9Rv3q +RAA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h5si2345625pgr.501.2018.02.08.04.37.11; Thu, 08 Feb 2018 04:37:26 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752178AbeBHMd7 (ORCPT + 99 others); Thu, 8 Feb 2018 07:33:59 -0500 Received: from bastet.se.axis.com ([195.60.68.11]:49076 "EHLO bastet.se.axis.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751066AbeBHMd4 (ORCPT ); Thu, 8 Feb 2018 07:33:56 -0500 Received: from localhost (localhost [127.0.0.1]) by bastet.se.axis.com (Postfix) with ESMTP id 89A8A1889E; Thu, 8 Feb 2018 13:33:55 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at bastet.se.axis.com Received: from bastet.se.axis.com ([IPv6:::ffff:127.0.0.1]) by localhost (bastet.se.axis.com [::ffff:127.0.0.1]) (amavisd-new, port 10024) with LMTP id FjRTrxDPCMka; Thu, 8 Feb 2018 13:33:53 +0100 (CET) Received: from boulder03.se.axis.com (boulder03.se.axis.com [10.0.8.17]) by bastet.se.axis.com (Postfix) with ESMTPS id AFE46188A1; Thu, 8 Feb 2018 13:33:53 +0100 (CET) Received: from boulder03.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9C4361E077; Thu, 8 Feb 2018 13:33:53 +0100 (CET) Received: from boulder03.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 910031E076; Thu, 8 Feb 2018 13:33:53 +0100 (CET) Received: from thoth.se.axis.com (unknown [10.0.2.173]) by boulder03.se.axis.com (Postfix) with ESMTP; Thu, 8 Feb 2018 13:33:53 +0100 (CET) Received: from lnxartpec1.se.axis.com (lnxartpec1.se.axis.com [10.88.4.10]) by thoth.se.axis.com (Postfix) with ESMTP id 848482D8B; Thu, 8 Feb 2018 13:33:53 +0100 (CET) Received: by lnxartpec1.se.axis.com (Postfix, from userid 20283) id 804D7401B8; Thu, 8 Feb 2018 13:33:53 +0100 (CET) From: Niklas Cassel To: kishon@ti.com, Arnd Bergmann , Greg Kroah-Hartman , Lorenzo Pieralisi Cc: Niklas Cassel , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/3] misc: pci_endpoint_test: Handle 64-bit BARs properly Date: Thu, 8 Feb 2018 13:33:45 +0100 Message-Id: <20180208123346.20784-3-niklas.cassel@axis.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180208123346.20784-1-niklas.cassel@axis.com> References: <20180208123346.20784-1-niklas.cassel@axis.com> X-TM-AS-GCONF: 00 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org A 64-bit BAR uses the succeeding BAR for the upper bits, so we cannot simply call pci_ioremap_bar() on every single BAR. Ignore BARs that does not have a valid resource length. pci 0000:01:00.0: BAR 4: assigned [mem 0xc0300000-0xc031ffff 64bit] pci 0000:01:00.0: BAR 2: assigned [mem 0xc0320000-0xc03203ff 64bit] pci 0000:01:00.0: BAR 0: assigned [mem 0xc0320400-0xc03204ff 64bit] pci-endpoint-test 0000:01:00.0: can't ioremap BAR 1: [??? 0x00000000 flags 0x0] pci-endpoint-test 0000:01:00.0: failed to read BAR1 pci-endpoint-test 0000:01:00.0: can't ioremap BAR 3: [??? 0x00000000 flags 0x0] pci-endpoint-test 0000:01:00.0: failed to read BAR3 pci-endpoint-test 0000:01:00.0: can't ioremap BAR 5: [??? 0x00000000 flags 0x0] pci-endpoint-test 0000:01:00.0: failed to read BAR5 Signed-off-by: Niklas Cassel --- Lorenzo/Bjorn: pci_resource_len() seems to fix my problem, but is it the correct function to use here? If BAR[x] is a 64-bit BAR, I'm assuming that pci_resource_len() on BAR[x+1] will always return 0 (since BAR[x+1] cannot have any prefetchable/type bits when BAR[x] is 64-bit). drivers/misc/pci_endpoint_test.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c index 320276f42653..3af31bfdcfdd 100644 --- a/drivers/misc/pci_endpoint_test.c +++ b/drivers/misc/pci_endpoint_test.c @@ -534,6 +534,8 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev, } for (bar = BAR_0; bar <= BAR_5; bar++) { + if (pci_resource_len(pdev, bar) == 0) + continue; base = pci_ioremap_bar(pdev, bar); if (!base) { dev_err(dev, "failed to read BAR%d\n", bar); -- 2.14.2