From: Niklas Cassel <cassel@kernel.org>
To: Bart Van Assche <bvanassche@acm.org>
Cc: linux-ide@vger.kernel.org, Damien Le Moal <dlemoal@kernel.org>,
Marco Elver <elver@google.com>, Jeff Garzik <jgarzik@redhat.com>,
Tejun Heo <htejun@gmail.com>
Subject: Re: [PATCH v2 1/9] ata: libata: Fix ata_exec_internal()
Date: Tue, 26 May 2026 15:43:12 +0200 [thread overview]
Message-ID: <ahWjcGUeSo76OIs3@ryzen> (raw)
In-Reply-To: <20260521173347.2079560-2-bvanassche@acm.org>
On Thu, May 21, 2026 at 10:33:29AM -0700, Bart Van Assche wrote:
> Some but not all ata_exec_internal() calls happen from the context of
> the ATA error handler. Commit c0c362b60e25 ("libata: implement cross-port
> EH exclusion") added ata_eh_release() and ata_eh_acquire() calls in
> ata_exec_internal(). Calling these functions is necessary if the caller
> holds the eh_mutex but is not allowed if the caller doesn't hold that
> mutex. Fix this by only calling ata_eh_release() and ata_eh_acquire() if
> the caller holds the eh_mutex. An example of an indirect caller of
> ata_exec_internal() that does not hold the eh_mutex is
> ata_host_register().
>
> Fixes: c0c362b60e25 ("libata: implement cross-port EH exclusion")
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
> drivers/ata/libata-core.c | 19 +++++++++++++++++--
> 1 file changed, 17 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
> index e76d15411e2a..3d25dec6ac6c 100644
> --- a/drivers/ata/libata-core.c
> +++ b/drivers/ata/libata-core.c
> @@ -1540,6 +1540,7 @@ unsigned int ata_exec_internal(struct ata_device *dev, struct ata_taskfile *tf,
> {
> struct ata_link *link = dev->link;
> struct ata_port *ap = link->ap;
> + const bool owns_eh_mutex = ap->host->eh_owner == current;
We have similar code in ata_msleep(), which does:
bool owns_eh = ap && ap->host->eh_owner == current;
do we perhaps want the "ap && " here as well?
> u8 command = tf->command;
> struct ata_queued_cmd *qc;
> struct scatterlist sgl;
> @@ -1617,11 +1618,25 @@ unsigned int ata_exec_internal(struct ata_device *dev, struct ata_taskfile *tf,
> }
> }
>
> - ata_eh_release(ap);
> + if (owns_eh_mutex) {
> + /*
> + * To prevent that the compiler complains about the
> + * ata_eh_release() call below.
> + */
> + __acquire(&ap->host->eh_mutex);
> + ata_eh_release(ap);
> + }
>
> rc = wait_for_completion_timeout(&wait, msecs_to_jiffies(timeout));
>
> - ata_eh_acquire(ap);
> + if (owns_eh_mutex) {
> + ata_eh_acquire(ap);
> + /*
> + * To prevent that the compiler complains about the above
> + * ata_eh_acquire() call.
> + */
> + __release(&ap->host->eh_mutex);
> + }
>
> ata_sff_flush_pio_task(ap);
>
Otherwise, this looks good to me:
Reviewed-by: Niklas Cassel <cassel@kernel.org>
next prev parent reply other threads:[~2026-05-26 13:43 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-21 17:33 [PATCH v2 0/9] ata: libata-core: Enable context analysis Bart Van Assche
2026-05-21 17:33 ` [PATCH v2 1/9] ata: libata: Fix ata_exec_internal() Bart Van Assche
2026-05-26 13:43 ` Niklas Cassel [this message]
2026-05-26 15:56 ` Bart Van Assche
2026-05-27 9:17 ` Niklas Cassel
2026-05-27 18:31 ` Damien Le Moal
2026-05-28 6:10 ` Hannes Reinecke
2026-05-21 17:33 ` [PATCH v2 2/9] ata: libata: Pass the ATA port argument directly to __ata_scsi_queuecmd() Bart Van Assche
2026-05-26 15:07 ` Niklas Cassel
2026-05-26 21:46 ` Bart Van Assche
2026-05-27 10:44 ` Niklas Cassel
2026-05-27 18:43 ` Damien Le Moal
2026-05-27 18:55 ` Bart Van Assche
2026-05-27 19:32 ` Damien Le Moal
2026-05-28 6:11 ` Hannes Reinecke
2026-05-21 17:33 ` [PATCH v2 3/9] ata: libata: Pass the ATA port argument directly to ata_qc_schedule_eh() Bart Van Assche
2026-05-21 17:33 ` [PATCH v2 4/9] ata: libata: Pass the ATA port argument directly to ata_qc_complete() Bart Van Assche
2026-05-21 18:40 ` sashiko-bot
2026-05-21 20:30 ` Bart Van Assche
2026-05-26 13:23 ` Niklas Cassel
2026-05-21 17:33 ` [PATCH v2 5/9] ata: libata: Pass the ATA port argument directly to ata_qc_issue() Bart Van Assche
2026-05-21 18:56 ` sashiko-bot
2026-05-21 17:33 ` [PATCH v2 6/9] ata: libata: Pass the ATA port argument directly to __ata_qc_complete() Bart Van Assche
2026-05-21 17:33 ` [PATCH v2 7/9] ata: libata: Pass the ATA port argument directly to ata_link_abort() Bart Van Assche
2026-05-21 19:14 ` sashiko-bot
2026-05-21 17:33 ` [PATCH v2 8/9] ata: libata: Enable context analysis Bart Van Assche
2026-05-21 20:17 ` sashiko-bot
2026-05-21 20:31 ` Bart Van Assche
2026-05-27 10:48 ` Niklas Cassel
2026-05-21 17:33 ` [PATCH v2 9/9] ata: Annotate the code that uses the host lock Bart Van Assche
2026-05-21 20:38 ` sashiko-bot
2026-05-26 15:16 ` Niklas Cassel
2026-05-26 21:33 ` Bart Van Assche
2026-05-26 22:37 ` Damien Le Moal
2026-05-26 22:40 ` Marco Elver
2026-05-27 13:42 ` Niklas Cassel
2026-05-27 10:57 ` Niklas Cassel
2026-05-27 18:51 ` Damien Le Moal
2026-05-27 18:54 ` Bart Van Assche
2026-05-27 19:34 ` Damien Le Moal
2026-05-27 9:20 ` (subset) [PATCH v2 0/9] ata: libata-core: Enable context analysis Niklas Cassel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ahWjcGUeSo76OIs3@ryzen \
--to=cassel@kernel.org \
--cc=bvanassche@acm.org \
--cc=dlemoal@kernel.org \
--cc=elver@google.com \
--cc=htejun@gmail.com \
--cc=jgarzik@redhat.com \
--cc=linux-ide@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox