Thread (62 messages) 62 messages, 4 authors, 2020-02-04

Re: [PATCH 08/15] devlink: add devres managed devlinkm_alloc and devlinkm_free

From: Jacob Keller <jacob.e.keller@intel.com>
Date: 2020-01-31 18:17:01

On 1/31/2020 10:07 AM, Jakub Kicinski wrote:
On Thu, 30 Jan 2020 14:59:03 -0800, Jacob Keller wrote:
quoted
Add devres managed allocation functions for allocating a devlink
instance. These can be used by device drivers based on the devres
framework which want to allocate a devlink instance.

For simplicity and to reduce churn in the devlink core code, the devres
management works by creating a node with a double-pointer. The devlink
instance is allocated using the normal devlink_alloc and released using
the normal devlink_free.

An alternative solution where the raw memory for devlink is allocated
directly via devres_alloc could be done. Such an implementation would
either significantly increase code duplication or code churn in order to
refactor the setup from the allocation.

The new devres managed allocation function will be used by the ice
driver in a following change to implement initial devlink support.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
How much are you actually going to gain by doing this given you still
have to deal with registering an unregistering all devlink things...
So, the main problem is that the ice driver's private PF structure is
allocated using devm_alloc.. and if we switch to using devlink_alloc
then that memory is no longer managed by devres and it becomes more
difficult to manage...

That being said, after looking at exactly how the ice driver uses devres
and managing things.. Probably not much gain in general. The ice driver
could implement its own call for this if we still need it.

In theory the register/unregister of devlink resources could be managed
by using devres_add_action to handle the teardown.. but that's a fairly
major refactor to get everything working.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help