Skip to content

ata: add __must_hold(ap->lock) annotations in issuing path

Niklas Cassel linux-ide 1 version Applied

Status from this message: Applied to libata/linux.git (for-7.2), thanks!

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 9 repliesApplied

Patches in v1 Applied

#Subject and filesSizeRepliesApplied
1/3ata: libata-scsi: Remove lockdep_assert_held() in ata_scsi_translate()drivers/ata/libata-scsi.c+0 -26 replies
2/3ata: libata: Pass ap parameter directly to functions in the issuing pathdrivers/ata/libata-core.c drivers/ata/libata-sata.c drivers/ata/libata-scsi.c +1 more+13 -141 reply
3/3ata: Annotate functions in the issuing path with __must_hold()drivers/ata/libata-core.c drivers/ata/libata-sata.c drivers/ata/libata-scsi.c +2 more+11 -31 reply

Reviews trailers per patch

All 3 patches have a Reviewed-by or Acked-by.

PatchHannes Reinecke
1/3R-b
2/3R-b
3/3R-b

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

Read the v1 thread

Cover letter [PATCH 0/3] ata: add __must_hold(ap->lock) annotations in issuing path

Hello all,

This series is meant to be applied on top of Bart's patch that already sets:
CONTEXT_ANALYSIS := y
and adds __must_hold(ap->host->eh_mutex) for EH functions.

This adds __must_hold(ap->lock) annotations in the issuing path.

This only adds annotations to a small number of functions. Additional functions can be annotated later.

By only annotating the issuing path, we are not blocked by first needing to fix some of the ata_port_freeze() callers not taking the lock.

I tried to look at nv_do_interrupt(), but AFAICT, it does take the lock.

I much prefer adding a "struct ata_port *ap" parameter to the issuing functions, because it avoids the problem that the context analysis cannot recognize that qc->ap == ap. (Since it relies on static code analysis.)

Because the alternative, adding a bunch of lockdep_assert_held() before a function call to a function annotated with __must_held(), simply tells the compiler to assume that the lock is held (because the lockdep_assert_held() macro has a call to __assume_ctx_lock()).

By adding an ap parameter, there is no need to assume any lock context, it can be verified all the way from the function taking the lock.

Kind regards,
Niklas

Bart Van Assche (2):
ata: libata: Pass ap parameter directly to functions in the issuing
path
ata: Annotate functions in the issuing path with __must_hold()

Niklas Cassel (1):
ata: libata-scsi: Remove lockdep_assert_held() in ata_scsi_translate()

 drivers/ata/libata-core.c |  6 +++---
 drivers/ata/libata-sata.c |  3 ++-
 drivers/ata/libata-scsi.c | 20 ++++++++++----------
 drivers/ata/libata.h      |  7 +++++--
 include/linux/libata.h    |  3 ++-
 5 files changed, 22 insertions(+), 17 deletions(-)
Signature · 1 line
2.54.0