Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp168391ybi; Fri, 24 May 2019 01:53:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqwUcQmH9jaIkZQGzTd3HvyNTrMN+AK0BtMcIz6mZcgK8Di07AhwsJDNs7IlM4OB0h1CZiUT X-Received: by 2002:a63:5105:: with SMTP id f5mr87277133pgb.373.1558688012817; Fri, 24 May 2019 01:53:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558688012; cv=none; d=google.com; s=arc-20160816; b=XCj6lzws0gO8p2aRb54kQdx/vhX1sSp2MowKUJO1/KOzBJAiPbkg2fHVUGE0qmHiih fsPBD+EB99vc7THMXZpreuBPN4pSTz9eSla1U5Xkuz+nIC3conRFQkQsrYF1tnHmtURR UaGbsV1WiK3LkJJVaaFlw3eU1NdCkVRquJyKwTnZt79RxAhSE67PtuDyutZIxt4Tw/jZ NyANXW+mlZf/150/KpAxRPBLvsYpe+ONGFnnnCK4z2GygFVYLc7HBMG/529fG0nuUy+M xHjytCrEWReghkuu2bemhKAIxuo4JAyjmFpaH53hTpQk/5bh2PRA2gZrPm4jnTpyOn0h TDdw== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:subject:dkim-signature; bh=Aje9IYjKWVDmlh2mOCB+vZPfc1Meqh7hIaNo9RIRcMs=; b=sqOuB9wyS/0PWAu5Lq35bgjjHauQ++puc6OFvnp0tCYqGZdyils5j1cnW+3Wgk/ZDK 4uwPUmyOKG+2MJsoZTsJn/frhiN2ryiVa+fSF4eu4BzdPRUt48SO6FZUuvgUgtfdKwuD cNiPSmHmd4wWo03Amtu7OxfoaycN7m6JhYQIAHRludlmBreRMlF867ZCcUxQQUSyUc26 uHRsa8lQOC+jhBHYVj4tFAtb7UscivEz/3KWgVOFs+PSeF0Z/RCLX+DAgThl618H/OaH tiomsdrQf+wHPOzvDuXnKoDEPXLV2Fz72eVrHz0zVMHeVCizTEBbMlIlEjT2x9Rkjey4 oqqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=QmK2v5jv; 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 129si3130584pfb.270.2019.05.24.01.53.14; Fri, 24 May 2019 01:53:32 -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=QmK2v5jv; 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 S2389724AbfEXIvG (ORCPT + 99 others); Fri, 24 May 2019 04:51:06 -0400 Received: from fllv0015.ext.ti.com ([198.47.19.141]:48556 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389612AbfEXIvG (ORCPT ); Fri, 24 May 2019 04:51:06 -0400 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id x4O8ovh5094264; Fri, 24 May 2019 03:50:57 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1558687857; bh=Aje9IYjKWVDmlh2mOCB+vZPfc1Meqh7hIaNo9RIRcMs=; h=Subject:To:References:From:Date:In-Reply-To; b=QmK2v5jvRYSYeDLbuCGoHeyk2u7tDrXAVYJWkzMEHfwk+sbe2PIikuxmpzpO2thCX H/OydCpeq2HfxCpZJRxBjAEOUksuSCIe9E2rqTGB7k90WbtJpYzCyOVvuwPhaPXQDm zS0DNQTqcKxeBuATkwHI439JFkhJZTVCyAm1UDUE= Received: from DLEE113.ent.ti.com (dlee113.ent.ti.com [157.170.170.24]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x4O8ovUt048595 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 24 May 2019 03:50:57 -0500 Received: from DLEE114.ent.ti.com (157.170.170.25) by DLEE113.ent.ti.com (157.170.170.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Fri, 24 May 2019 03:50:57 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DLEE114.ent.ti.com (157.170.170.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Fri, 24 May 2019 03:50:57 -0500 Received: from [172.24.190.233] (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id x4O8or34125751; Fri, 24 May 2019 03:50:54 -0500 Subject: Re: [PATCH v2] PCI: endpoint: Skip odd BAR when skipping 64bit BAR To: Alan Mikhak , , , , , Palmer Dabbelt , Paul Walmsley , Bjorn Helgaas , , , References: <1558648540-14239-1-git-send-email-alan.mikhak@sifive.com> From: Kishon Vijay Abraham I Message-ID: Date: Fri, 24 May 2019 14:19:39 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US 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 Hi, On 24/05/19 5:25 AM, Alan Mikhak wrote: > +Bjorn Helgaas, +Gustavo Pimentel, +Wen Yang, +Kangjie Lu > > On Thu, May 23, 2019 at 2:55 PM Alan Mikhak wrote: >> >> Always skip odd bar when skipping 64bit BARs in pci_epf_test_set_bar() >> and pci_epf_test_alloc_space(). >> >> Otherwise, pci_epf_test_set_bar() will call pci_epc_set_bar() on odd loop >> index when skipping reserved 64bit BAR. Moreover, pci_epf_test_alloc_space() >> will call pci_epf_alloc_space() on bind for odd loop index when BAR is 64bit >> but leaks on subsequent unbind by not calling pci_epf_free_space(). >> >> Signed-off-by: Alan Mikhak >> Reviewed-by: Paul Walmsley >> --- >> drivers/pci/endpoint/functions/pci-epf-test.c | 25 ++++++++++++------------- >> 1 file changed, 12 insertions(+), 13 deletions(-) >> >> diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/endpoint/functions/pci-epf-test.c >> index 27806987e93b..96156a537922 100644 >> --- a/drivers/pci/endpoint/functions/pci-epf-test.c >> +++ b/drivers/pci/endpoint/functions/pci-epf-test.c >> @@ -389,7 +389,7 @@ static void pci_epf_test_unbind(struct pci_epf *epf) >> >> static int pci_epf_test_set_bar(struct pci_epf *epf) >> { >> - int bar; >> + int bar, add; >> int ret; >> struct pci_epf_bar *epf_bar; >> struct pci_epc *epc = epf->epc; >> @@ -400,8 +400,14 @@ static int pci_epf_test_set_bar(struct pci_epf *epf) >> >> epc_features = epf_test->epc_features; >> >> - for (bar = BAR_0; bar <= BAR_5; bar++) { >> + for (bar = BAR_0; bar <= BAR_5; bar += add) { >> epf_bar = &epf->bar[bar]; >> + /* >> + * pci_epc_set_bar() sets PCI_BASE_ADDRESS_MEM_TYPE_64 >> + * if the specific implementation required a 64-bit BAR, >> + * even if we only requested a 32-bit BAR. >> + */ set_bar shouldn't set PCI_BASE_ADDRESS_MEM_TYPE_64. If a platform supports only 64-bit BAR, that should be specified in epc_features bar_fixed_64bit member. Thanks Kishon