Received: by 10.223.185.116 with SMTP id b49csp6317685wrg; Thu, 8 Mar 2018 05:35:56 -0800 (PST) X-Google-Smtp-Source: AG47ELvBD/KON5QZP+wbsau5mLR0cb2WlNv7yJseAvGgQF+Ez7rWaroPBligLUpxmuHBN4j3b4cf X-Received: by 2002:a17:902:7485:: with SMTP id h5-v6mr24541625pll.236.1520516156865; Thu, 08 Mar 2018 05:35:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520516156; cv=none; d=google.com; s=arc-20160816; b=bp3oESudnN/RAnjiB7cd/eeBB7Zmn0PbZgco2VxpmpnRjagWgapBfifFfgaG+ZjV3M oi1nOrOjILxIJ0h9lywa5Obt6I6f6gbSCJ/QRd/wetLUKTyCNmkIgV7QGh/GokEqzZ2A 8K3LhhjGKXYCZNphEsCRz7+Ro0wmwx8RJz9/yBEAzYfvV0ArW/+WTwZAADA4GFcGQRS2 zov2w5DLYdBMf6trTRLxgMONWfL0lYxTa40GRrCmZgfkCiDKv9vfek1YfqPI3r+Bf6Jr pcB4Wpy4ZkBCDtS4vVpjpc9cOR3WWk4H9VrcrPzp7/AWyyTMO18Y1h9L8poAT/8TPWBt a3SQ== 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=hMfQNqWElzdhuzXHC50dboGwD8rNKvws0/ocx+KvpRQ=; b=fvTC54GoAN3ciXu8dl3X40GqGArnmWs5TQ1H555VRj8WUBaF6etoh3cKcMxZ0xJiG8 n8BWP//6GXZuaF9AtPPJdCXc+r/vWAfJo2g5bF1NYBi5Y4ebRDdYUN/JdJ8Pa8CNE1Lt lD2yWSyUXGKvH1drqGiBf8G79TK56I8yDamKoc+6TPd0IBzo321mdyncEjO6EdtH5+hv s89sHSO39DiZ/4sz0/iczOwTdxeiO7ZX1U1DTzcXM7v535YiRmFSgLVtd+ygK3CJdRh6 uGov5CRTRGZLumHWlbXT76oGrFMuW7382W3bCMLFkiqGDJYyJMPOb62YX4n4uWvnbILO 20sg== 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 t21-v6si14758494plo.79.2018.03.08.05.35.28; Thu, 08 Mar 2018 05:35:56 -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 S934930AbeCHNeD (ORCPT + 99 others); Thu, 8 Mar 2018 08:34:03 -0500 Received: from bastet.se.axis.com ([195.60.68.11]:60678 "EHLO bastet.se.axis.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755935AbeCHNeB (ORCPT ); Thu, 8 Mar 2018 08:34:01 -0500 Received: from localhost (localhost [127.0.0.1]) by bastet.se.axis.com (Postfix) with ESMTP id 658B118766; Thu, 8 Mar 2018 14:33:59 +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 R1Wemp6pGgTq; Thu, 8 Mar 2018 14:33:57 +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 4F27D1876B; Thu, 8 Mar 2018 14:33:57 +0100 (CET) Received: from boulder02.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3D9651A082; Thu, 8 Mar 2018 14:33:57 +0100 (CET) Received: from boulder02.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 32A611A066; Thu, 8 Mar 2018 14:33:57 +0100 (CET) Received: from seth.se.axis.com (unknown [10.0.2.172]) by boulder02.se.axis.com (Postfix) with ESMTP; Thu, 8 Mar 2018 14:33:57 +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 267322A71; Thu, 8 Mar 2018 14:33:57 +0100 (CET) Received: by lnxartpec1.se.axis.com (Postfix, from userid 20283) id 217FB401A5; Thu, 8 Mar 2018 14:33:57 +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 v4 5/5] misc: pci_endpoint_test: Handle 64-bit BARs properly Date: Thu, 8 Mar 2018 14:33:30 +0100 Message-Id: <20180308133331.19464-6-niklas.cassel@axis.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180308133331.19464-1-niklas.cassel@axis.com> References: <20180308133331.19464-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 consists of a BAR pair, where the second BAR has the upper bits, so we cannot simply call pci_ioremap_bar() on every single BAR index. The second BAR in a BAR pair will not have the IORESOURCE_MEM resource flag set. Only call ioremap on BARs that have the IORESOURCE_MEM resource flag set. 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 --- drivers/misc/pci_endpoint_test.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c index 320276f42653..fe8897e64635 100644 --- a/drivers/misc/pci_endpoint_test.c +++ b/drivers/misc/pci_endpoint_test.c @@ -534,12 +534,14 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev, } for (bar = BAR_0; bar <= BAR_5; bar++) { - base = pci_ioremap_bar(pdev, bar); - if (!base) { - dev_err(dev, "failed to read BAR%d\n", bar); - WARN_ON(bar == test_reg_bar); + if (pci_resource_flags(pdev, bar) & IORESOURCE_MEM) { + base = pci_ioremap_bar(pdev, bar); + if (!base) { + dev_err(dev, "failed to read BAR%d\n", bar); + WARN_ON(bar == test_reg_bar); + } + test->bar[bar] = base; } - test->bar[bar] = base; } test->base = test->bar[test_reg_bar]; -- 2.14.2