Received: by 10.213.65.68 with SMTP id h4csp1326446imn; Thu, 29 Mar 2018 02:36:38 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/zzMi3dXp7zFBnLP/U+TJNnR4/5KVVJOIkHyzCNdSgvpBLRjdmCTtwFyekVKE8CnW/YA3O X-Received: by 2002:a17:902:6b85:: with SMTP id p5-v6mr7705629plk.66.1522316198905; Thu, 29 Mar 2018 02:36:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522316198; cv=none; d=google.com; s=arc-20160816; b=HbYM2YTHQkbAyKcK9GI3eBlbs/eUzMRthkecSUyZdg4Zcb7BS3/X2DcNK/JnYTa5MA c/aY499StGdlfCdf3L8plZ3r7MR3o4iCUKhuRqSmvNAGXaLBcYWKxsDUFYxOh6cZroBx drAkUCQTgq8ziTdAIOQ6Q7MXFSeaJs2FVXb6KNtFeZauMlleKCcrN7oWYKNnu3QdrueS Q2oIKPZbrIjZ1hERTtv2D2Bek2RZaET3jzvJqGDX6rDCeHsXWiNpE94OgqIo3at9Va5/ koS9IklORnRJep53bhoKfTvJ3Zyi4lclneTDW19IoCm0KYHuB5GRxWjl7Dqblyo/+7Yv DqOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject:dkim-signature:arc-authentication-results; bh=BCutSLkhscY660PLWzIg8iBtlUFhn7B7fyqpDktEJ8M=; b=tlO9f8F481IDQHnXHo7KCnnUuRWF8lGzcHuR2W8ov6EUouVfH8vdAWmDWq9rrb5Xbw m4MNe17LrGVzO+7fZJXdayZ747iLPsGkXaoYfghLpv3nZ770HjiPo3iaWrm5IJwqiLIT LFUmE9FqZQ13cvsWpRBt+hs6yjFPWN6FtkE7RHquUTOap3P4ldQjVFQ/7c/M8DT3Zi/1 yf/ixiT0Ime/ISIeNUzk5y+hGKq4YLP8M9/B6J71zfxqtwCAHY+Esx51hmuK0J3WPYSk bqYxV2JHCP6fqP9DaNGf22yCcQ8ebLLWCNB5yr/nOVcosBV/YiflGEpQ4L9mXjYkqUr5 UwhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=OHg8xoF2; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ay2-v6si5222728plb.749.2018.03.29.02.36.24; Thu, 29 Mar 2018 02:36:38 -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; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=OHg8xoF2; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752105AbeC2Jfd (ORCPT + 99 others); Thu, 29 Mar 2018 05:35:33 -0400 Received: from fllnx210.ext.ti.com ([198.47.19.17]:42610 "EHLO fllnx210.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750884AbeC2Jfc (ORCPT ); Thu, 29 Mar 2018 05:35:32 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by fllnx210.ext.ti.com (8.15.1/8.15.1) with ESMTP id w2T9ZAQF013979; Thu, 29 Mar 2018 04:35:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1522316110; bh=1H3Ipw2SBuby0kVU0DWR9tqJEpQnF0XplNCmiLP9dJ4=; h=Subject:To:References:CC:From:Date:In-Reply-To; b=OHg8xoF2v1ZpEzs2bqquBcbC4BiMRa65pzfHVy6XuWuXi9dlfR7474wust6eGr3r/ XuDkntLJl8h5NoMCGTaUJmgggq9oABmzlLC9FykNUhvVCQhhMl9s0Lv48adnuQHegn mgMJg4ZW3eLjHjATW5Va844CHB8lFBbC8QGlKt5Q= Received: from DLEE115.ent.ti.com (dlee115.ent.ti.com [157.170.170.26]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id w2T9Z9pk000867; Thu, 29 Mar 2018 04:35:10 -0500 Received: from DLEE101.ent.ti.com (157.170.170.31) by DLEE115.ent.ti.com (157.170.170.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1261.35; Thu, 29 Mar 2018 04:35:09 -0500 Received: from dlep32.itg.ti.com (157.170.170.100) by DLEE101.ent.ti.com (157.170.170.31) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1261.35 via Frontend Transport; Thu, 29 Mar 2018 04:35:09 -0500 Received: from [172.24.190.233] (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id w2T9Z6aW002759; Thu, 29 Mar 2018 04:35:06 -0500 Subject: Re: [PATCH v5 01/12] PCI: endpoint: BAR width should not depend on sizeof dma_addr_t To: Niklas Cassel , , Lorenzo Pieralisi , Bjorn Helgaas , Sekhar Nori , Shawn Lin , Niklas Cassel , John Keeping References: <20180328115018.31921-1-niklas.cassel@axis.com> <20180328115018.31921-2-niklas.cassel@axis.com> CC: , From: Kishon Vijay Abraham I Message-ID: <01244df4-165b-77bb-e542-26e33dc0d348@ti.com> Date: Thu, 29 Mar 2018 15:05:03 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <20180328115018.31921-2-niklas.cassel@axis.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wednesday 28 March 2018 05:20 PM, Niklas Cassel wrote: > 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 Acked-by: Kishon Vijay Abraham I > --- > 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); >