Received: by 10.213.65.68 with SMTP id h4csp345213imn; Wed, 28 Mar 2018 04:52:18 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/BYFCQwXKxu4/ohnvKF5PDhfF+k7niAcnex4Vi2yY3vGAHyJGZ1EHBXyKWBrrJhncV1bIJ X-Received: by 2002:a17:902:2f03:: with SMTP id s3-v6mr3639387plb.274.1522237938265; Wed, 28 Mar 2018 04:52:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522237938; cv=none; d=google.com; s=arc-20160816; b=MyZ/gKvZZmx8FoQR3biAc15WTLHAs8JhSa+NR9bPgmyvaFGpeFBbLPZt7VX8N6KwzP 4BzqsNIqc1c2eALbUyzkKqxu8xVhyyKkWdlH5Fs8grbW6r564P9YGVCTP+M/uTKy/Wfc bDhWc1Zcew7b6aCJM7DFtIikX2uFJz8TnJRB5FCwqrXhVyBzo4D4nE7U3yE9P+D/6mOw GkrnekpSwUDmBaqBQioJnXaNLcvEYPAD0CB1sOCghaS2I4HucYNFvkX0t+6w/UtPKeAL jbxXxyMGZYGCSeKVdT5+vC8AdVUwg6DMCkP37xhTIA+moCZYlJD56jFc3Gab2BA267CL l4lw== 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=e4HA/D3mOkiuQVllc6rS+0ACcx1yPuB1tDT0PjlJ4WY=; b=nI80fGkFjCkOZFXMmtMhoQpmqnQ6jxc25ZQ70GpUvzbwPR+VcpzFGy/ZCAsYamWIg9 zpkgEbpHJ0R7Lc2e3zqt5AdvIpimd13eTQ823lV0GmZZQ5d988ay/toWOlXtB5wI7tOs QD3Qryda3qjXujQzA+pHv7wl6iMWZvSiUo6SaNUacn9jnupprUUcmYHfVDDuCx5tFx5K +JMTRA5381vGrzqalm1MF1mKxBPY2Nl6VjJ8NnWXK/Uv7CRAXhdS4GU97W4IJvxT7Qed CcFoYaDPXWytLqNgGfp0vSl35oFURWQK65k55up9u7fDJQs8yAEf/PMaxBX/GH/kbHFm SRHA== 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 x3-v6si3517900plb.366.2018.03.28.04.52.02; Wed, 28 Mar 2018 04:52:18 -0700 (PDT) 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 S1752675AbeC1Lug (ORCPT + 99 others); Wed, 28 Mar 2018 07:50:36 -0400 Received: from bastet.se.axis.com ([195.60.68.11]:53856 "EHLO bastet.se.axis.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751207AbeC1Lua (ORCPT ); Wed, 28 Mar 2018 07:50:30 -0400 Received: from localhost (localhost [127.0.0.1]) by bastet.se.axis.com (Postfix) with ESMTP id E54A61842F; Wed, 28 Mar 2018 13:50:28 +0200 (CEST) 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 UVDUk5mpUP-9; Wed, 28 Mar 2018 13:50:28 +0200 (CEST) Received: from boulder02.se.axis.com (boulder02.se.axis.com [10.0.8.16]) by bastet.se.axis.com (Postfix) with ESMTPS id E90BF1806E; Wed, 28 Mar 2018 13:50:27 +0200 (CEST) Received: from boulder02.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D77F01A077; Wed, 28 Mar 2018 13:50:27 +0200 (CEST) Received: from boulder02.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CB5601A06D; Wed, 28 Mar 2018 13:50:27 +0200 (CEST) Received: from seth.se.axis.com (unknown [10.0.2.172]) by boulder02.se.axis.com (Postfix) with ESMTP; Wed, 28 Mar 2018 13:50:27 +0200 (CEST) Received: from lnxartpec1.se.axis.com (lnxartpec1.se.axis.com [10.88.4.10]) by seth.se.axis.com (Postfix) with ESMTP id BE1FF20D7; Wed, 28 Mar 2018 13:50:27 +0200 (CEST) Received: by lnxartpec1.se.axis.com (Postfix, from userid 20283) id B73ED40197; Wed, 28 Mar 2018 13:50:27 +0200 (CEST) From: Niklas Cassel To: kishon@ti.com, cyrille.pitchen@free-electrons.com, Lorenzo Pieralisi , Bjorn Helgaas , Sekhar Nori , Shawn Lin , Niklas Cassel , John Keeping Cc: Niklas Cassel , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 01/12] PCI: endpoint: BAR width should not depend on sizeof dma_addr_t Date: Wed, 28 Mar 2018 13:50:06 +0200 Message-Id: <20180328115018.31921-2-niklas.cassel@axis.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180328115018.31921-1-niklas.cassel@axis.com> References: <20180328115018.31921-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). If a certain hardware doesn't support 64-bit BARs, its epc->ops->set_bar() implementation should return -EINVAL when PCI_BASE_ADDRESS_MEM_TYPE_64 is set. We can't change pci_epc_set_bar() to only set PCI_BASE_ADDRESS_MEM_TYPE_64 based on size, since if the user, for some reason, wants to configure a BAR with a 64-bit width, even though the BAR size is less than 4 GB, he should be able to do that. However, since pci-epf-test is simply a test and not an API, we can set PCI_BASE_ADDRESS_MEM_TYPE_64 in pci-epf-test itself only based on size. Signed-off-by: Niklas Cassel --- drivers/pci/endpoint/functions/pci-epf-test.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/endpoint/functions/pci-epf-test.c index 64d8a17f8094..f6c0c59b1bc8 100644 --- a/drivers/pci/endpoint/functions/pci-epf-test.c +++ b/drivers/pci/endpoint/functions/pci-epf-test.c @@ -70,7 +70,7 @@ struct pci_epf_test_data { bool linkup_notifier; }; -static int bar_size[] = { 512, 512, 1024, 16384, 131072, 1048576 }; +static size_t bar_size[] = { 512, 512, 1024, 16384, 131072, 1048576 }; static int pci_epf_test_copy(struct pci_epf_test *epf_test) { @@ -367,12 +367,14 @@ 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]; + + flags = PCI_BASE_ADDRESS_SPACE_MEMORY; + flags |= upper_32_bits(epf_bar->size) ? + PCI_BASE_ADDRESS_MEM_TYPE_64 : + PCI_BASE_ADDRESS_MEM_TYPE_32; + ret = pci_epc_set_bar(epc, epf->func_no, bar, epf_bar->phys_addr, epf_bar->size, flags); -- 2.14.2