Received: by 10.223.176.5 with SMTP id f5csp2931174wra; Thu, 1 Feb 2018 08:12:24 -0800 (PST) X-Google-Smtp-Source: AH8x227otPtAJ3DIArO+PHTW7tje9HnFheDHKjiJNhp6UyPUf3Vb8lgMdfJtfbS3r3WrDfGIsINX X-Received: by 10.98.156.71 with SMTP id f68mr37783247pfe.29.1517501544320; Thu, 01 Feb 2018 08:12:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517501544; cv=none; d=google.com; s=arc-20160816; b=SMMQAma23iu03UxHcHuk0NiXfXSj8TCzR03JHdQr0RAW9XwYP6yF3SN/MQp7imS94j SKIlTqR9C1FQUG/OJLc/DRplKLcLrxsNC1nJyjhUZ8KCvua3nvr8xG1SEbtfdr/w4Vtl cabvGybXJ2jm8iusJYPaB06hX2bTRbxbRVMJpAfRkKBj5dF5xHiDOBppG6Gdsc/p9oYH Xvo4uVoOCDsPv1bFWFAvxJDyqhEhIqWqEvR7oKjte1A1cuDVh+alPAVKcJDUmMHjZqVe z6Fokcq4bECc6oGsW3ZW1D36gQKybroSrISethZpbV0XMZlZFZ7CPEkXqPqIoG6hQq+A EoJQ== 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=ZlT4B2+3HChGzh6g63ANznJ9s/AATUVpZn5767wFE+WvgFPJ38tllbjhR+bAtAvKfH IVS+vUz81PT7fC9kBxcjMhR22JkJTLvNb1f71mMnRjDA9/uAbJ6Gbt7yxuoBahjSLEFl n4cBwt0EdK+G60RcffmwDGI0X5J1z6IslZS6ZB/aJYWBVYncu3V801eQcef+t+H9GZmh JZAescFlg+Z2kb+reDcym5uuxaMfgx3quLdXOmu49INfEYG/SneVpGJMSXI6dsdNJdFF y2VdeuiiPVEZaZcrxo0kBuq75N1zlyie+Z63czfXlL/HsEc3o5clCYLnjPM8YO7okLsa dg6Q== 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 bc11-v6si4026828plb.531.2018.02.01.08.12.09; Thu, 01 Feb 2018 08:12:24 -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 S1752646AbeBAQLi (ORCPT + 99 others); Thu, 1 Feb 2018 11:11:38 -0500 Received: from bastet.se.axis.com ([195.60.68.11]:40558 "EHLO bastet.se.axis.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751881AbeBAQLd (ORCPT ); Thu, 1 Feb 2018 11:11:33 -0500 Received: from localhost (localhost [127.0.0.1]) by bastet.se.axis.com (Postfix) with ESMTP id 92324187F6; Thu, 1 Feb 2018 17:11:31 +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 t4oPlxXL2Olu; Thu, 1 Feb 2018 17:11:29 +0100 (CET) Received: from boulder02.se.axis.com (boulder02.se.axis.com [10.0.8.16]) by bastet.se.axis.com (Postfix) with ESMTPS id AA2D8187EE; Thu, 1 Feb 2018 17:11:29 +0100 (CET) Received: from boulder02.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 993381A073; Thu, 1 Feb 2018 17:11:29 +0100 (CET) Received: from boulder02.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8DD2A1A072; Thu, 1 Feb 2018 17:11:29 +0100 (CET) Received: from seth.se.axis.com (unknown [10.0.2.172]) by boulder02.se.axis.com (Postfix) with ESMTP; Thu, 1 Feb 2018 17:11:29 +0100 (CET) Received: from lnxartpec1.se.axis.com (lnxartpec1.se.axis.com [10.88.4.10]) by seth.se.axis.com (Postfix) with ESMTP id 814C828B; Thu, 1 Feb 2018 17:11:29 +0100 (CET) Received: by lnxartpec1.se.axis.com (Postfix, from userid 20283) id 7BD0E401AF; Thu, 1 Feb 2018 17:11:29 +0100 (CET) From: Niklas Cassel To: kishon@ti.com, Lorenzo Pieralisi , Arnd Bergmann , Greg Kroah-Hartman Cc: Niklas Cassel , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] misc: pci_endpoint_test: Handle 64-bit BARs properly Date: Thu, 1 Feb 2018 17:11:18 +0100 Message-Id: <20180201161119.3852-3-niklas.cassel@axis.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180201161119.3852-1-niklas.cassel@axis.com> References: <20180201161119.3852-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