Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp4058576pxb; Tue, 17 Nov 2020 10:09:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJwfFzKVR/Xmn3ZdANpr4QcsU+KpGMiONwvI2rzGK7CUDXZINoOzysrmKhC0eaXn2Om+T0lZ X-Received: by 2002:a1c:7fd7:: with SMTP id a206mr315444wmd.135.1605636562800; Tue, 17 Nov 2020 10:09:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605636562; cv=none; d=google.com; s=arc-20160816; b=goibfc3G9W79hDsOFWcFc6wYodvempXfWk3M2HTk1euHjSnIOgoRHi6yVV61eQUEs8 Pacws2HQgCqRvLLRGdz+4+NwUMGekWRCwqTq/G2QDhz+n2EcTBx6rnhGmKoaCEtoDCjY Hidtuk3UtTvdaNnXAf7Z0kaQKD4RImpzY16PGvVIVdgEqKbJKy6j1focSqbvOiM6JATM gBMBUovofOMJwuPg0ls5NO4GZzho7EF9RzhlmbO96w56mZj35a9PUg8V5dbPHuQZwWLS gP9+HPS92sHqPz8aGVbaQGaU6eaSouLO8OGrC7qU5d0HqtU34iCF0tzFTy0leQDIUlQz ts/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date:ironport-sdr:ironport-sdr; bh=du6tVVSEHTpznlq/6x1LybV1O2ghhTz/AOGfmz7M0r8=; b=B1nwZc3DQvRzCs0S/Z2JfFSuChdQsbhYLD84pFBZupG94JcE2Alk9ytOnK+sZwYI4k 64kIWcatjAAal3j3YTq26GeP24GD0OXu6qfAOmapkerNMoimjT6L5k3zlRghZdBSiDaE blumOpX91VIQ2CFE6atuTsng27tGWXNC0CyfW/76+dpja67IqpUtZPu6MWxcfqCh3+eS iOfXJ65UC7WrSZjzBkGmSfrk8qToIiI6HNoDYSTSO1JTs1luJhxGPYg+IDoMzRtXwVeo 8BBky1Kh/9/TIMS+uQtDVD74vuYbZ05hgBPRRCzYnFC+M+iC8g/mDaeFMJwZlNfGQTNT yXOw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cz19si13621201edb.512.2020.11.17.10.08.58; Tue, 17 Nov 2020 10:09:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729091AbgKQSFQ (ORCPT + 99 others); Tue, 17 Nov 2020 13:05:16 -0500 Received: from mga03.intel.com ([134.134.136.65]:5483 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725808AbgKQSFQ (ORCPT ); Tue, 17 Nov 2020 13:05:16 -0500 IronPort-SDR: VDEJwy+vHvt/nsZOUUIbpr1L0S5o2hKQj1Z6jvsTJAkkAfnLTIsACCAd65f/42hPeJvg5P4/zn 88Y0KUjMPObw== X-IronPort-AV: E=McAfee;i="6000,8403,9808"; a="171075780" X-IronPort-AV: E=Sophos;i="5.77,486,1596524400"; d="scan'208";a="171075780" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Nov 2020 10:04:17 -0800 IronPort-SDR: cYXAPD2WmBzP4e9fps4JN9ZeNfrkm8AblXNjmvv2r3mtj0KgIl03LmIJprn3PsqSWFm5l6Epm7 wo1QBJkfPCjw== X-IronPort-AV: E=Sophos;i="5.77,486,1596524400"; d="scan'208";a="476011145" Received: from rhweight-wrk1.ra.intel.com ([137.102.106.140]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Nov 2020 10:04:15 -0800 Date: Tue, 17 Nov 2020 10:05:12 -0800 (PST) From: matthew.gerlach@linux.intel.com X-X-Sender: mgerlach@rhweight-WRK1 To: "Wu, Hao" cc: "linux-fpga@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "mdf@kernel.org" , "trix@redhat.com" , "linux-doc@vger.kernel.org" , "corbet@lwn.net" Subject: RE: [PATCH 1/2] fpga: dfl: refactor cci_enumerate_feature_devs() In-Reply-To: Message-ID: References: <20201117012552.262149-1-matthew.gerlach@linux.intel.com> <20201117012552.262149-2-matthew.gerlach@linux.intel.com> User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 17 Nov 2020, Wu, Hao wrote: >> Subject: [PATCH 1/2] fpga: dfl: refactor cci_enumerate_feature_devs() >> >> From: Matthew Gerlach >> >> In preparation of looking for dfls based on a vendor >> specific pcie capability, move code that assumes >> Bar0/offset0 as start of DFL to its own function. >> >> Signed-off-by: Matthew Gerlach >> --- >> drivers/fpga/dfl-pci.c | 86 ++++++++++++++++++++++++------------------ >> 1 file changed, 49 insertions(+), 37 deletions(-) >> >> diff --git a/drivers/fpga/dfl-pci.c b/drivers/fpga/dfl-pci.c >> index a2203d03c9e2..b1b157b41942 100644 >> --- a/drivers/fpga/dfl-pci.c >> +++ b/drivers/fpga/dfl-pci.c >> @@ -119,49 +119,20 @@ static int *cci_pci_create_irq_table(struct pci_dev >> *pcidev, unsigned int nvec) >> return table; >> } >> >> -/* enumerate feature devices under pci device */ >> -static int cci_enumerate_feature_devs(struct pci_dev *pcidev) >> +static int find_dfl_in_bar0(struct pci_dev *pcidev, >> + struct dfl_fpga_enum_info *info) >> { >> - struct cci_drvdata *drvdata = pci_get_drvdata(pcidev); >> - int port_num, bar, i, nvec, ret = 0; >> - struct dfl_fpga_enum_info *info; >> - struct dfl_fpga_cdev *cdev; >> resource_size_t start, len; >> + int port_num, bar, i; >> void __iomem *base; >> - int *irq_table; >> + int ret = 0; >> u32 offset; >> u64 v; >> >> - /* allocate enumeration info via pci_dev */ >> - info = dfl_fpga_enum_info_alloc(&pcidev->dev); >> - if (!info) >> - return -ENOMEM; >> - >> - /* add irq info for enumeration if the device support irq */ >> - nvec = cci_pci_alloc_irq(pcidev); >> - if (nvec < 0) { >> - dev_err(&pcidev->dev, "Fail to alloc irq %d.\n", nvec); >> - ret = nvec; >> - goto enum_info_free_exit; >> - } else if (nvec) { >> - irq_table = cci_pci_create_irq_table(pcidev, nvec); >> - if (!irq_table) { >> - ret = -ENOMEM; >> - goto irq_free_exit; >> - } >> - >> - ret = dfl_fpga_enum_info_add_irq(info, nvec, irq_table); >> - kfree(irq_table); >> - if (ret) >> - goto irq_free_exit; >> - } >> - >> - /* start to find Device Feature List in Bar 0 */ >> + /* start to find Device Feature List from Bar 0 */ >> base = cci_pci_ioremap_bar0(pcidev); >> - if (!base) { >> - ret = -ENOMEM; >> - goto irq_free_exit; >> - } >> + if (!base) >> + return -ENOMEM; >> >> /* >> * PF device has FME and Ports/AFUs, and VF device only has one >> @@ -208,12 +179,53 @@ static int cci_enumerate_feature_devs(struct >> pci_dev *pcidev) >> dfl_fpga_enum_info_add_dfl(info, start, len); >> } else { >> ret = -ENODEV; >> - goto irq_free_exit; >> } >> >> /* release I/O mappings for next step enumeration */ >> pcim_iounmap_regions(pcidev, BIT(0)); >> >> + > > We don't need 2 blank line here, remove one please. I will remove this line in v2. > >> + return ret; >> +} >> + >> +/* enumerate feature devices under pci device */ >> +static int cci_enumerate_feature_devs(struct pci_dev *pcidev) >> +{ >> + struct cci_drvdata *drvdata = pci_get_drvdata(pcidev); >> + struct dfl_fpga_enum_info *info; >> + struct dfl_fpga_cdev *cdev; >> + int nvec, ret = 0; >> + int *irq_table; >> + >> + /* allocate enumeration info via pci_dev */ >> + info = dfl_fpga_enum_info_alloc(&pcidev->dev); >> + if (!info) >> + return -ENOMEM; >> + >> + /* add irq info for enumeration if the device support irq */ >> + nvec = cci_pci_alloc_irq(pcidev); >> + if (nvec < 0) { >> + dev_err(&pcidev->dev, "Fail to alloc irq %d.\n", nvec); >> + ret = nvec; >> + goto enum_info_free_exit; >> + } else if (nvec) { >> + irq_table = cci_pci_create_irq_table(pcidev, nvec); >> + if (!irq_table) { >> + ret = -ENOMEM; >> + goto irq_free_exit; >> + } >> + >> + ret = dfl_fpga_enum_info_add_irq(info, nvec, irq_table); >> + kfree(irq_table); >> + if (ret) >> + goto irq_free_exit; >> + } >> + >> + ret = find_dfl_in_bar0(pcidev, info); >> + > > Remove this blank line, and maybe switch to a better function name here. I will remove blank line in v2 and use your suggested function name, find_dfls_by_default. > > Thanks > Hao > >> + if (ret) >> + goto irq_free_exit; >> + >> /* start enumeration with prepared enumeration information */ >> cdev = dfl_fpga_feature_devs_enumerate(info); >> if (IS_ERR(cdev)) { >> -- >> 2.25.2 > >