From nobody Mon Nov 25 15:43:37 2024 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C961A214439; Fri, 25 Oct 2024 22:37:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729895863; cv=none; b=jl6x9+hCJEmeiOib6eIwBGl3OegzTeRYr5cn6GUu9wSkhza6caaxv0i1RXZTz5+IbBy21s/NxLqGH6rTVB/oQcqHvatlpGMZ14RhzP1K/SI1SKd1l1zP3siNZ/rwM9az0BM1md3vVU7D4j6wzRdVl8n3E1SrKiZqk0BFQs9+9Pg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729895863; c=relaxed/simple; bh=XihtfDMd0o78dix3GOFl+cpu1wKBIMLXii1mSNYMCXw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rC2LIq+Qa3WLb5pcw6QT7BhY+57TZafgFdkvpuYlDNpvRvdC32WwN+hs722Pm1KsgRGTBSzRvb5OqkPNyjWbsJ+nl6IQIZyh+O0QEJgfoLaMvA1aqlXvxrsvxti+05N9PIuZPTInmVjS4XKC8EnyFe5/U83HMSjbSSVENnGnkCQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=OlUUeKDH; arc=none smtp.client-ip=192.198.163.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="OlUUeKDH" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1729895861; x=1761431861; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XihtfDMd0o78dix3GOFl+cpu1wKBIMLXii1mSNYMCXw=; b=OlUUeKDHELABXIl40nVxcDE2jpjHiACQ4S4ahYPxIK+XqIaMrb6QLU4q InultSeuLS1Nh4TgIo/AjZa/exsldmiZrp8hmLph3o3yRHmQ/qSD9A6YD P4YTQQKb0bAOfeGEmIMvANuONJPqrTOTYXl8jnpVeSmYyX22pInlBkWy4 VLPlLvInwcyTnQgQ5u6CA0m9B2CHZqB8r62ZXyvSe7Lkvvcz29wPum7GX BCQLwjqrvwXjjr1LyTxgnfzmp/LDPfnJm4asaaO4rajxPBHP8xop7EjRD 572nC7CurPDdrhMqp7tBkE/ZmL3zI5mYFi58rUTS+XO1PsSOuqVtNxqDO A==; X-CSE-ConnectionGUID: YhmhWY88S+KYPwZ/DtTOeg== X-CSE-MsgGUID: Kvmhexa5TBG+r9cYVyUIvQ== X-IronPort-AV: E=McAfee;i="6700,10204,11236"; a="29474646" X-IronPort-AV: E=Sophos;i="6.11,233,1725346800"; d="scan'208";a="29474646" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Oct 2024 15:37:37 -0700 X-CSE-ConnectionGUID: K3yIrUrpRH+k2W0PNESVww== X-CSE-MsgGUID: f+5RDEfzQPapJ8R2JZz9NA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,233,1725346800"; d="scan'208";a="85596153" Received: from sj-4150-psse-sw-opae-dev3.sj.altera.com ([10.244.138.109]) by fmviesa005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Oct 2024 15:37:37 -0700 From: Peter Colberg To: Wu Hao , Tom Rix , Moritz Fischer , Xu Yilun , linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Russ Weight , Marco Pagani , Matthew Gerlach , Basheer Ahmed Muddebihal , Peter Colberg Subject: [PATCH v4 07/19] fpga: dfl: store FIU type in feature platform data Date: Fri, 25 Oct 2024 18:37:02 -0400 Message-ID: <20241025223714.394533-8-peter.colberg@intel.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241025223714.394533-1-peter.colberg@intel.com> References: <20241025223714.394533-1-peter.colberg@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Remove the local function feature_dev_id_type() in favor of persisting the FIU type in struct dfl_feature_platform_data. Add type to struct build_feature_devs_info and drop argument to build_info_create_dev(). Signed-off-by: Peter Colberg Reviewed-by: Matthew Gerlach Reviewed-by: Basheer Ahmed Muddebihal --- Changes since v3: - Revert change that converts is_feature_dev_detected() to use FIU type, which has been factored out into a separate, second to last patch. - Restore Christmas tree order of local variable declarations in binfo_create_feature_dev_data(). - Replace "favour" with "favor" in description. Changes since v2: - New patch extracted from monolithic v1 patch. --- drivers/fpga/dfl.c | 55 ++++++++++++++++++++++------------------------ drivers/fpga/dfl.h | 3 +++ 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/drivers/fpga/dfl.c b/drivers/fpga/dfl.c index 56a32f5146a3..86fcd3084b06 100644 --- a/drivers/fpga/dfl.c +++ b/drivers/fpga/dfl.c @@ -119,17 +119,6 @@ static void dfl_id_free(enum dfl_id_type type, int id) mutex_unlock(&dfl_id_mutex); } =20 -static enum dfl_id_type feature_dev_id_type(struct platform_device *pdev) -{ - int i; - - for (i =3D 0; i < ARRAY_SIZE(dfl_devs); i++) - if (!strcmp(dfl_devs[i].name, pdev->name)) - return i; - - return DFL_ID_MAX; -} - static enum dfl_id_type dfh_id_to_type(u16 id) { int i; @@ -379,7 +368,7 @@ dfl_dev_add(struct dfl_feature_platform_data *pdata, if (ret) goto put_dev; =20 - ddev->type =3D feature_dev_id_type(pdev); + ddev->type =3D pdata->type; ddev->feature_id =3D feature->id; ddev->revision =3D feature->revision; ddev->dfh_version =3D feature->dfh_version; @@ -693,6 +682,7 @@ EXPORT_SYMBOL_GPL(dfl_fpga_dev_ops_unregister); * @irq_table: Linux IRQ numbers for all irqs, indexed by local irq index = of * this device. * @feature_dev: current feature device. + * @type: the current FIU type. * @ioaddr: header register region address of current FIU in enumeration. * @start: register resource start of current FIU. * @len: max register resource length of current FIU. @@ -706,6 +696,7 @@ struct build_feature_devs_info { int *irq_table; =20 struct platform_device *feature_dev; + enum dfl_id_type type; void __iomem *ioaddr; resource_size_t start; resource_size_t len; @@ -754,11 +745,10 @@ binfo_create_feature_dev_data(struct build_feature_de= vs_info *binfo) { struct platform_device *fdev =3D binfo->feature_dev; struct dfl_feature_platform_data *pdata; + enum dfl_id_type type =3D binfo->type; struct dfl_feature_info *finfo, *p; - enum dfl_id_type type; int index =3D 0, res_idx =3D 0; =20 - type =3D feature_dev_id_type(fdev); if (WARN_ON_ONCE(type >=3D DFL_ID_MAX)) return ERR_PTR(-EINVAL); =20 @@ -773,6 +763,7 @@ binfo_create_feature_dev_data(struct build_feature_devs= _info *binfo) return ERR_PTR(-ENOMEM); =20 pdata->dev =3D fdev; + pdata->type =3D type; pdata->num =3D binfo->feature_num; pdata->dfl_cdev =3D binfo->cdev; pdata->id =3D FEATURE_DEV_ID_UNUSED; @@ -859,14 +850,11 @@ binfo_create_feature_dev_data(struct build_feature_de= vs_info *binfo) } =20 static int -build_info_create_dev(struct build_feature_devs_info *binfo, - enum dfl_id_type type) +build_info_create_dev(struct build_feature_devs_info *binfo) { + enum dfl_id_type type =3D binfo->type; struct platform_device *fdev; =20 - if (type >=3D DFL_ID_MAX) - return -EINVAL; - /* * we use -ENODEV as the initialization indicator which indicates * whether the id need to be reclaimed @@ -903,7 +891,7 @@ static int build_info_commit_dev(struct build_feature_d= evs_info *binfo) if (ret) return ret; =20 - if (feature_dev_id_type(binfo->feature_dev) =3D=3D PORT_ID) + if (binfo->type =3D=3D PORT_ID) dfl_fpga_cdev_add_port_data(binfo->cdev, pdata); else binfo->cdev->fme_dev =3D get_device(&binfo->feature_dev->dev); @@ -917,6 +905,9 @@ static int build_info_commit_dev(struct build_feature_d= evs_info *binfo) */ binfo->feature_dev =3D NULL; =20 + /* reset the binfo for next FIU */ + binfo->type =3D DFL_ID_MAX; + return 0; } =20 @@ -929,8 +920,7 @@ static void build_info_free(struct build_feature_devs_i= nfo *binfo) * build_info_create_dev() */ if (binfo->feature_dev && binfo->feature_dev->id >=3D 0) { - dfl_id_free(feature_dev_id_type(binfo->feature_dev), - binfo->feature_dev->id); + dfl_id_free(binfo->type, binfo->feature_dev->id); =20 list_for_each_entry_safe(finfo, p, &binfo->sub_features, node) { list_del(&finfo->node); @@ -1028,7 +1018,7 @@ static int parse_feature_irqs(struct build_feature_de= vs_info *binfo, * Instead, features with interrupt functionality provide * the information in feature specific registers. */ - type =3D feature_dev_id_type(binfo->feature_dev); + type =3D binfo->type; if (type =3D=3D PORT_ID) { switch (fid) { case PORT_FEATURE_ID_UINT: @@ -1230,7 +1220,7 @@ static int parse_feature_afu(struct build_feature_dev= s_info *binfo, return -EINVAL; } =20 - switch (feature_dev_id_type(binfo->feature_dev)) { + switch (binfo->type) { case PORT_ID: return parse_feature_port_afu(binfo, ofst); default: @@ -1276,6 +1266,7 @@ static void build_info_complete(struct build_feature_= devs_info *binfo) static int parse_feature_fiu(struct build_feature_devs_info *binfo, resource_size_t ofst) { + enum dfl_id_type type; int ret =3D 0; u32 offset; u16 id; @@ -1297,8 +1288,14 @@ static int parse_feature_fiu(struct build_feature_de= vs_info *binfo, v =3D readq(binfo->ioaddr + DFH); id =3D FIELD_GET(DFH_ID, v); =20 + type =3D dfh_id_to_type(id); + if (type >=3D DFL_ID_MAX) + return -EINVAL; + + binfo->type =3D type; + /* create platform device for dfl feature dev */ - ret =3D build_info_create_dev(binfo, dfh_id_to_type(id)); + ret =3D build_info_create_dev(binfo); if (ret) return ret; =20 @@ -1518,13 +1515,13 @@ EXPORT_SYMBOL_GPL(dfl_fpga_enum_info_add_irq); =20 static int remove_feature_dev(struct device *dev, void *data) { + struct dfl_feature_platform_data *pdata =3D dev_get_platdata(dev); struct platform_device *pdev =3D to_platform_device(dev); - enum dfl_id_type type =3D feature_dev_id_type(pdev); int id =3D pdev->id; =20 platform_device_unregister(pdev); =20 - dfl_id_free(type, id); + dfl_id_free(pdata->type, id); =20 return 0; } @@ -1576,6 +1573,7 @@ dfl_fpga_feature_devs_enumerate(struct dfl_fpga_enum_= info *info) goto unregister_region_exit; } =20 + binfo->type =3D DFL_ID_MAX; binfo->dev =3D info->dev; binfo->cdev =3D cdev; =20 @@ -1628,8 +1626,7 @@ void dfl_fpga_feature_devs_remove(struct dfl_fpga_cde= v *cdev) =20 /* remove released ports */ if (!device_is_registered(&port_dev->dev)) { - dfl_id_free(feature_dev_id_type(port_dev), - port_dev->id); + dfl_id_free(pdata->type, port_dev->id); platform_device_put(port_dev); } =20 diff --git a/drivers/fpga/dfl.h b/drivers/fpga/dfl.h index 8ef9f33e22c1..d3a8a8ef908b 100644 --- a/drivers/fpga/dfl.h +++ b/drivers/fpga/dfl.h @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -308,6 +309,7 @@ struct dfl_feature { * @lock: mutex to protect platform data. * @cdev: cdev of feature dev. * @dev: ptr to platform device linked with this platform data. + * @type: type of DFL FIU for the feature dev. See enum dfl_id_type. * @dfl_cdev: ptr to container device. * @id: id used for this feature device. * @disable_count: count for port disable. @@ -322,6 +324,7 @@ struct dfl_feature_platform_data { struct mutex lock; struct cdev cdev; struct platform_device *dev; + enum dfl_id_type type; struct dfl_fpga_cdev *dfl_cdev; int id; unsigned int disable_count; --=20 2.47.0