Skip to content

ethtool: allow nesting of begin() and complete() callbacks

Michal Kubecek linux-wireless lkml netdev 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest3 patches 3 repliesIn review
  2. v13 patches 2 repliesSuperseded

Changes in v2 from the cover letter

- fix inverted condition in epic100 ethtool_begin() (thanks to Andrew Lunn)

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3wil6210: get rid of begin() and complete() ethtool_opsdrivers/net/wireless/ath/wil6210/ethtool.c+16 -271 reply
2/3via-velocity: allow nesting of ethtool_ops begin() and complete()drivers/net/ethernet/via/via-velocity.c drivers/net/ethernet/via/via-velocity.h+11 -40 replies
3/3epic100: allow nesting of ethtool_ops begin() and complete()drivers/net/ethernet/smsc/epic100.c+5 -20 replies

Reviews trailers per patch

1 of 3 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchSimon HormanFlorian Fainelli
SeriesR-b
1/3R-b
2/3
3/3

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH net-next v2 0/3] ethtool: allow nesting of begin() and complete() callbacks

The ethtool ioctl interface used to guarantee that ethtool_ops callbacks were always called in a block between calls to ->begin() and ->complete() (if these are defined) and that this whole block was executed with RTNL lock held:

	rtnl_lock();
	ops->begin();
	/* other ethtool_ops calls */
	ops->complete();
	rtnl_unlock();

This prevented any nesting or crossing of the begin-complete blocks. However, this is no longer guaranteed even for ioctl interface as at least ethtool_phys_id() releases RTNL lock while waiting for a timer. With the introduction of netlink ethtool interface, the begin-complete pairs are naturally nested e.g. when a request triggers a netlink notification.

Fortunately, only minority of networking drivers implements begin() and complete() callbacks and most of those that do, fall into three groups:

- wrappers for pm_runtime_get_sync() and pm_runtime_put()
- wrappers for clk_prepare_enable() and clk_disable_unprepare()
- begin() checks netif_running() (fails if false), no complete()

First two have their own refcounting, third is safe w.r.t. nesting of the blocks.

Only three in-tree networking drivers need an update to deal with nesting of begin() and complete() calls: via-velocity and epic100 perform resume and suspend on their own and wil6210 completely serializes the calls using its own mutex (which would lead to a deadlock if a request request triggered a netlink notification). The series addresses these problems.

changes between v1 and v2:
- fix inverted condition in epic100 ethtool_begin() (thanks to Andrew Lunn)

Michal Kubecek (3):
wil6210: get rid of begin() and complete() ethtool_ops
via-velocity: allow nesting of ethtool_ops begin() and complete()
epic100: allow nesting of ethtool_ops begin() and complete()

 drivers/net/ethernet/smsc/epic100.c        |  7 +++-
 drivers/net/ethernet/via/via-velocity.c    | 14 +++++--
 drivers/net/ethernet/via/via-velocity.h    |  1 +
 drivers/net/wireless/ath/wil6210/ethtool.c | 43 ++++++++--------------
 4 files changed, 32 insertions(+), 33 deletions(-)
Signature · 1 line
2.24.1