Linux ATA/IDE development
 help / color / mirror / Atom feed
* [PATCH 0/3] ata: add __must_hold(ap->lock) annotations in issuing path
@ 2026-05-28 17:28 Niklas Cassel
  2026-05-28 17:28 ` [PATCH 1/3] ata: libata-scsi: Remove lockdep_assert_held() in ata_scsi_translate() Niklas Cassel
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Niklas Cassel @ 2026-05-28 17:28 UTC (permalink / raw)
  To: Damien Le Moal; +Cc: Bart Van Assche, Marco Elver, linux-ide, Niklas Cassel

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(-)

-- 
2.54.0


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2026-05-29  6:42 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-28 17:28 [PATCH 0/3] ata: add __must_hold(ap->lock) annotations in issuing path Niklas Cassel
2026-05-28 17:28 ` [PATCH 1/3] ata: libata-scsi: Remove lockdep_assert_held() in ata_scsi_translate() Niklas Cassel
2026-05-28 17:33   ` Bart Van Assche
2026-05-28 17:54     ` Niklas Cassel
2026-05-28 19:48       ` Bart Van Assche
2026-05-28 17:51   ` sashiko-bot
2026-05-29  6:22   ` Hannes Reinecke
2026-05-29  6:42   ` Damien Le Moal
2026-05-28 17:28 ` [PATCH 2/3] ata: libata: Pass ap parameter directly to functions in the issuing path Niklas Cassel
2026-05-29  6:22   ` Hannes Reinecke
2026-05-28 17:28 ` [PATCH 3/3] ata: Annotate functions in the issuing path with __must_hold() Niklas Cassel
2026-05-29  6:23   ` Hannes Reinecke

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox