Received: by 10.223.185.116 with SMTP id b49csp6316949wrg; Thu, 8 Mar 2018 05:35:11 -0800 (PST) X-Google-Smtp-Source: AG47ELuWTKeGEiqZgZIPODaSp+GFaJEoEb/ogDS3Ptac50HC7LAR+zTscKjIF+1l0ld8CAHbdDfk X-Received: by 10.98.248.7 with SMTP id d7mr26553682pfh.117.1520516111556; Thu, 08 Mar 2018 05:35:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520516111; cv=none; d=google.com; s=arc-20160816; b=Qetg/hobNKGgTWHRJ1dBC4Xobxkbv0ldcCO91D5wXrjTD8tCptdgDYy1oWNX28JoTD wLSalLooxFa2LPKWLzOHDhPIMoyoUlnq6LsFKeG0Kld0X09IMwtV1MCay/Imhg/RvukQ ldM0Vf9JgqiyQPlO7SFJ5JY9ZHg+Pk2SdASBi0yhQ1/0h0z/LvRoOOKcBcsDV72hc3GF OVBKKf2RW7RSOtnKynxYMLlPoz0hdnns789N6FyGkEa+iadxnPNgiO4XYnwo59tFEPTR kSSescoIOxM/1DAK0CftkaWJIonQejokDxbZtVawPZaCH8Z9hf/sOlZjMa6fU5YVD0sk 2m+A== 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=Zg1koiCvQZn0ChmC68slnprlEq1lDmT1ZANuKemXiwU=; b=JT7JnrvHujFNaCRPG+cz73pNtiYL6EbFdXf66XFH9eed6ucVg108UvOp4AAkYSuUU9 y24OeCgdD/tGnT02V1XRuySnv6jW1io262X5uW7TMtcbntXoMoVNjizyZyV80HTgQlKF YxkAJFgwUdffKfXiD1KyZkHDC6ZdMGfNOb3QWph0/E+z9/k5de2zlRDRSyf7whny+X5J iFUoHC8oqLfVVM/4tPvS5fjGv0DgJ96VyP+XQMXsKM21Aeqhc9EbQKFQMXTI3JHhYcbo d+ZUZakYyLgIlPEWckPEq2uLg1Y2lFTMCAQX0fpvEL8wOaWznQ1ySthdUrHxbI27I23D bDNg== 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 l19si12836737pgc.239.2018.03.08.05.34.47; Thu, 08 Mar 2018 05:35:11 -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 S1755915AbeCHNdo (ORCPT + 99 others); Thu, 8 Mar 2018 08:33:44 -0500 Received: from bastet.se.axis.com ([195.60.68.11]:60570 "EHLO bastet.se.axis.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755824AbeCHNdl (ORCPT ); Thu, 8 Mar 2018 08:33:41 -0500 Received: from localhost (localhost [127.0.0.1]) by bastet.se.axis.com (Postfix) with ESMTP id 2BC5118771; Thu, 8 Mar 2018 14:33:40 +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 9jR31fmaJYtw; Thu, 8 Mar 2018 14:33:39 +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 D78051876E; Thu, 8 Mar 2018 14:33:38 +0100 (CET) Received: from boulder02.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C147C1A088; Thu, 8 Mar 2018 14:33:38 +0100 (CET) Received: from boulder02.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B4D251A06B; Thu, 8 Mar 2018 14:33:38 +0100 (CET) Received: from thoth.se.axis.com (unknown [10.0.2.173]) by boulder02.se.axis.com (Postfix) with ESMTP; Thu, 8 Mar 2018 14:33:38 +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 A82CB2AB5; Thu, 8 Mar 2018 14:33:38 +0100 (CET) Received: by lnxartpec1.se.axis.com (Postfix, from userid 20283) id A4495401A5; Thu, 8 Mar 2018 14:33:38 +0100 (CET) From: Niklas Cassel To: kishon@ti.com, Lorenzo Pieralisi , Bjorn Helgaas , Sekhar Nori , John Keeping , Shawn Lin , Niklas Cassel , Cyrille Pitchen Cc: Niklas Cassel , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 1/5] PCI: endpoint: BAR width should not depend on sizeof dma_addr_t Date: Thu, 8 Mar 2018 14:33:26 +0100 Message-Id: <20180308133331.19464-2-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 If a BAR supports 64-bit width or not depends on the hardware, and should thus not depend on sizeof(dma_addr_t). Since this driver is generic, default to always using BAR width of 32-bits. 64-bit BARs can easily be tested by replacing PCI_BASE_ADDRESS_MEM_TYPE_32 with PCI_BASE_ADDRESS_MEM_TYPE_64 in bar_flags. Signed-off-by: Niklas Cassel --- Note to Lorenzo/Bjorn: It is not trivial to convert the bar_size + bar_flags + struct pci_epf->bar member array to an array of struct resources, since we need to be able to store the addresses returned by dma_alloc_coherent(), which is of type dma_addr_t. struct resource uses resource_size_t, which is defined as phys_addr_t. E.g. ARTPEC-7 uses 64-bit dma_addr_t, but only 32-bit phys_addr_t. drivers/pci/endpoint/functions/pci-epf-test.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/endpoint/functions/pci-epf-test.c index 800da09d9005..7c70433b11a7 100644 --- a/drivers/pci/endpoint/functions/pci-epf-test.c +++ b/drivers/pci/endpoint/functions/pci-epf-test.c @@ -71,6 +71,14 @@ struct pci_epf_test_data { }; static int bar_size[] = { 512, 512, 1024, 16384, 131072, 1048576 }; +static int bar_flags[] = { + PCI_BASE_ADDRESS_SPACE_MEMORY | PCI_BASE_ADDRESS_MEM_TYPE_32, + PCI_BASE_ADDRESS_SPACE_MEMORY | PCI_BASE_ADDRESS_MEM_TYPE_32, + PCI_BASE_ADDRESS_SPACE_MEMORY | PCI_BASE_ADDRESS_MEM_TYPE_32, + PCI_BASE_ADDRESS_SPACE_MEMORY | PCI_BASE_ADDRESS_MEM_TYPE_32, + PCI_BASE_ADDRESS_SPACE_MEMORY | PCI_BASE_ADDRESS_MEM_TYPE_32, + PCI_BASE_ADDRESS_SPACE_MEMORY | PCI_BASE_ADDRESS_MEM_TYPE_32 +}; static int pci_epf_test_copy(struct pci_epf_test *epf_test) { @@ -358,7 +366,6 @@ static void pci_epf_test_unbind(struct pci_epf *epf) static int pci_epf_test_set_bar(struct pci_epf *epf) { - int flags; int bar; int ret; struct pci_epf_bar *epf_bar; @@ -367,15 +374,11 @@ static int pci_epf_test_set_bar(struct pci_epf *epf) struct pci_epf_test *epf_test = epf_get_drvdata(epf); enum pci_barno test_reg_bar = epf_test->test_reg_bar; - flags = PCI_BASE_ADDRESS_SPACE_MEMORY | PCI_BASE_ADDRESS_MEM_TYPE_32; - if (sizeof(dma_addr_t) == 0x8) - flags |= PCI_BASE_ADDRESS_MEM_TYPE_64; - for (bar = BAR_0; bar <= BAR_5; bar++) { epf_bar = &epf->bar[bar]; ret = pci_epc_set_bar(epc, epf->func_no, bar, epf_bar->phys_addr, - epf_bar->size, flags); + epf_bar->size, bar_flags[bar]); if (ret) { pci_epf_free_space(epf, epf_test->reg[bar], bar); dev_err(dev, "failed to set BAR%d\n", bar); -- 2.14.2