On Thu, Sep 24, 2026 at 12:59:15PM +0000, Sergey Temerkhanov wrote: > ice_ptp_lock() conditionally retains ctrl_pf_lock for read when it > successfully acquires the hardware semaphore. The matching unlock occurs > in ice_ptp_unlock(). Describe this cross-function handoff with context > analysis annotations so static analysis can verify callers. > > Signed-off-by: Sergey Temerkhanov <[email protected]> > Reviewed-by: Przemyslaw Korba <[email protected]> > --- > drivers/net/ethernet/intel/ice/ice.h | 12 ++++++++++ > drivers/net/ethernet/intel/ice/ice_ptp_hw.c | 26 +++++++++++++-------- > drivers/net/ethernet/intel/ice/ice_ptp_hw.h | 6 +++-- > 3 files changed, 32 insertions(+), 12 deletions(-) > > diff --git a/drivers/net/ethernet/intel/ice/ice.h > b/drivers/net/ethernet/intel/ice/ice.h > index c454f19a2cb2..8b7891ac25b0 100644 > --- a/drivers/net/ethernet/intel/ice/ice.h > +++ b/drivers/net/ethernet/intel/ice/ice.h > @@ -1179,4 +1179,16 @@ static inline struct ice_pf *ice_get_ctrl_pf(struct > ice_pf *pf) > rcu_dereference_check(pf->adapter->ctrl_pf, > > lockdep_is_held(&pf->adapter->ctrl_pf_lock)); > } > + > +/* container_of() expands to a statement expression, which clang cannot parse > + * inside a context analysis attribute argument, so open-code the cast here. > + */ > +#define ice_hw_ctrl_pf_lock(_hw) \ > + (&((struct ice_pf *)((void *)(_hw) - \ > + offsetof(struct ice_pf, > hw)))->adapter->ctrl_pf_lock)
FWIW, another alternative to open coding container_of(), which I don't love to see, is using a static inline function, which would likely read better as well. https://lore.kernel.org/f147ad227b85439d56183e60e0332547b84441bc.1790360262.git.bvanass...@acm.org/ -- Cheers, Nathan
