Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit af4fa7ea authored by Jakub Kicinski's avatar Jakub Kicinski Committed by David S. Miller
Browse files

nfp: remove automatic caching of RTsym table



The fact that RTsym table is cached inside nfp_cpp handle is
a relic of old times when nfpcore was a library module.  All
the nfp_cpp "caches" are awkward to deal with because of
concurrency and prone to keeping stale information.  Make
the run time symbol table be an object read out from the device
and managed by whoever requested it.  Since the driver loads
FW at ->probe() and never reloads, we can hold onto the table
for ever.

Signed-off-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ab832b8d
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -77,7 +77,7 @@ static int nfp_pcie_sriov_read_nfd_limit(struct nfp_pf *pf)
{
	int err;

	pf->limit_vfs = nfp_rtsym_read_le(pf->cpp, "nfd_vf_cfg_max_vfs", &err);
	pf->limit_vfs = nfp_rtsym_read_le(pf->rtbl, "nfd_vf_cfg_max_vfs", &err);
	if (!err)
		return pci_sriov_set_totalvfs(pf->pdev, pf->limit_vfs);

@@ -373,6 +373,8 @@ static int nfp_pci_probe(struct pci_dev *pdev,
	if (err)
		goto err_devlink_unreg;

	pf->rtbl = nfp_rtsym_table_read(pf->cpp);

	err = nfp_pcie_sriov_read_nfd_limit(pf);
	if (err)
		goto err_fw_unload;
@@ -394,6 +396,7 @@ static int nfp_pci_probe(struct pci_dev *pdev,
err_sriov_unlimit:
	pci_sriov_set_totalvfs(pf->pdev, 0);
err_fw_unload:
	kfree(pf->rtbl);
	if (pf->fw_loaded)
		nfp_fw_unload(pf);
	kfree(pf->eth_tbl);
@@ -430,6 +433,7 @@ static void nfp_pci_remove(struct pci_dev *pdev)

	devlink_unregister(devlink);

	kfree(pf->rtbl);
	if (pf->fw_loaded)
		nfp_fw_unload(pf);

+3 −0
Original line number Diff line number Diff line
@@ -56,6 +56,7 @@ struct nfp_cpp_area;
struct nfp_eth_table;
struct nfp_net;
struct nfp_nsp_identify;
struct nfp_rtsym_table;

/**
 * struct nfp_pf - NFP PF-specific device structure
@@ -70,6 +71,7 @@ struct nfp_nsp_identify;
 * @num_vfs:		Number of SR-IOV VFs enabled
 * @fw_loaded:		Is the firmware loaded?
 * @ctrl_vnic:		Pointer to the control vNIC if available
 * @rtbl:		RTsym table
 * @eth_tbl:		NSP ETH table
 * @nspi:		NSP identification info
 * @hwmon_dev:		pointer to hwmon device
@@ -101,6 +103,7 @@ struct nfp_pf {

	struct nfp_net *ctrl_vnic;

	struct nfp_rtsym_table *rtbl;
	struct nfp_eth_table *eth_tbl;
	struct nfp_nsp_identify *nspi;

+2 −2
Original line number Diff line number Diff line
@@ -201,7 +201,7 @@ nfp_net_pf_rtsym_read_optional(struct nfp_pf *pf, const char *format,

	snprintf(name, sizeof(name), format, nfp_cppcore_pcie_unit(pf->cpp));

	val = nfp_rtsym_read_le(pf->cpp, name, &err);
	val = nfp_rtsym_read_le(pf->rtbl, name, &err);
	if (err) {
		if (err == -ENOENT)
			return default_val;
@@ -234,7 +234,7 @@ nfp_net_pf_map_rtsym(struct nfp_pf *pf, const char *name, const char *sym_fmt,
	snprintf(pf_symbol, sizeof(pf_symbol), sym_fmt,
		 nfp_cppcore_pcie_unit(pf->cpp));

	sym = nfp_rtsym_lookup(pf->cpp, pf_symbol);
	sym = nfp_rtsym_lookup(pf->rtbl, pf_symbol);
	if (!sym) {
		nfp_err(pf->cpp, "Failed to find PF symbol %s\n", pf_symbol);
		return (u8 __iomem *)ERR_PTR(-ENOENT);
+0 −4
Original line number Diff line number Diff line
@@ -224,10 +224,6 @@ int nfp_cpp_serial(struct nfp_cpp *cpp, const u8 **serial);

void *nfp_hwinfo_cache(struct nfp_cpp *cpp);
void nfp_hwinfo_cache_set(struct nfp_cpp *cpp, void *val);
void *nfp_rtsym_cache(struct nfp_cpp *cpp);
void nfp_rtsym_cache_set(struct nfp_cpp *cpp, void *val);

void nfp_nffw_cache_flush(struct nfp_cpp *cpp);

struct nfp_cpp_area *nfp_cpp_area_alloc_with_name(struct nfp_cpp *cpp,
						  u32 cpp_id,
+0 −26
Original line number Diff line number Diff line
@@ -78,7 +78,6 @@ struct nfp_cpp_resource {
 *
 * Following fields can be used only in probe() or with rtnl held:
 * @hwinfo:		HWInfo database fetched from the device
 * @rtsym:		firmware run time symbols
 *
 * Following fields use explicit locking:
 * @resource_list:	NFP CPP resource list
@@ -109,7 +108,6 @@ struct nfp_cpp {
	struct list_head area_cache_list;

	void *hwinfo;
	void *rtsym;
};

/* Element of the area_cache_list */
@@ -234,7 +232,6 @@ void nfp_cpp_free(struct nfp_cpp *cpp)
		cpp->op->free(cpp);

	kfree(cpp->hwinfo);
	kfree(cpp->rtsym);

	device_unregister(&cpp->dev);

@@ -286,29 +283,6 @@ void nfp_hwinfo_cache_set(struct nfp_cpp *cpp, void *val)
	cpp->hwinfo = val;
}

void *nfp_rtsym_cache(struct nfp_cpp *cpp)
{
	return cpp->rtsym;
}

void nfp_rtsym_cache_set(struct nfp_cpp *cpp, void *val)
{
	cpp->rtsym = val;
}

/**
 * nfp_nffw_cache_flush() - Flush cached firmware information
 * @cpp:	NFP CPP handle
 *
 * Flush cached firmware information.  This function should be called
 * every time firmware is loaded on unloaded.
 */
void nfp_nffw_cache_flush(struct nfp_cpp *cpp)
{
	kfree(nfp_rtsym_cache(cpp));
	nfp_rtsym_cache_set(cpp, NULL);
}

/**
 * nfp_cpp_area_alloc_with_name() - allocate a new CPP area
 * @cpp:	CPP device handle
Loading