ata: libata-core: Synchronize ata_port_detach() with hotplug
authorDamien Le Moal <dlemoal@kernel.org>
Mon, 28 Aug 2023 06:57:11 +0000 (15:57 +0900)
committerDamien Le Moal <dlemoal@kernel.org>
Tue, 3 Oct 2023 00:39:49 +0000 (09:39 +0900)
The call to async_synchronize_cookie() to synchronize a port removal
and hotplug probe is done in ata_host_detach() right before calling
ata_port_detach(). Move this call at the beginning of ata_port_detach()
to ensure that this operation is always synchronized with probe.

Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Tested-by: Chia-Lin Kao (AceLan) <acelan.kao@canonical.com>
Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/ata/libata-core.c

index 5afd30d76f0bb21273d345c601fa506b284e2398..2b7b88e74c2b47c3d729810cd61457c551c2199f 100644 (file)
@@ -6065,6 +6065,9 @@ static void ata_port_detach(struct ata_port *ap)
        struct ata_link *link;
        struct ata_device *dev;
 
+       /* Ensure ata_port probe has completed */
+       async_synchronize_cookie(ap->cookie + 1);
+
        /* Wait for any ongoing EH */
        ata_port_wait_eh(ap);
 
@@ -6129,11 +6132,8 @@ void ata_host_detach(struct ata_host *host)
 {
        int i;
 
-       for (i = 0; i < host->n_ports; i++) {
-               /* Ensure ata_port probe has completed */
-               async_synchronize_cookie(host->ports[i]->cookie + 1);
+       for (i = 0; i < host->n_ports; i++)
                ata_port_detach(host->ports[i]);
-       }
 
        /* the host is dead now, dissociate ACPI */
        ata_acpi_dissociate(host);