From patchwork Sat Sep 23 00:29:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 13396454 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 21717CE7A8B for ; Sat, 23 Sep 2023 00:30:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230522AbjIWAaO (ORCPT ); Fri, 22 Sep 2023 20:30:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230498AbjIWAaC (ORCPT ); Fri, 22 Sep 2023 20:30:02 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 720421B5; Fri, 22 Sep 2023 17:29:56 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D9780C433CC; Sat, 23 Sep 2023 00:29:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695428996; bh=HuQHvEmRjsflkMBvRlfx+zSVsAeF4E9Jq7Sw4Ms5+6w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JWMrJy6d/o5QJxM1XPfLSmH5B9e/vfx8RmvIX7VBr+Xm/jVFi4PdX0sNwcX0SkA7k gVYZLPhYNWe8v6YTfMyTZ7ozfL+xIOOCngILeLZVIt2lFoMPmK9YhlY3HLl1aWoy7F CY6VpxOYUBGtR9+BVOmql/Wic7CMG39gao3wriLZmF7ZLaBACxEkDZcvguhzuLAkLm kYoAyU1rckC9OEr1N75Xggua/DmpKUWAxspwt6Oh+yRdLWQWFUZVecImPpV0q8CM4/ MITie5xi7ne4NtoHb4Tp0fPQSmoZzyzEcF6dRy+0IVeyiYUaVkqvxbb7K2roxC/uJu kRFYcbm0qujZg== From: Damien Le Moal To: linux-ide@vger.kernel.org Cc: linux-scsi@vger.kernel.org, "Martin K . Petersen" , John Garry , Rodrigo Vivi , Paul Ausbeck , Kai-Heng Feng , Joe Breuer , Geert Uytterhoeven , Chia-Lin Kao Subject: [PATCH v6 14/23] ata: libata-core: Synchronize ata_port_detach() with hotplug Date: Sat, 23 Sep 2023 09:29:23 +0900 Message-ID: <20230923002932.1082348-15-dlemoal@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230923002932.1082348-1-dlemoal@kernel.org> References: <20230923002932.1082348-1-dlemoal@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org 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 Reviewed-by: Hannes Reinecke Tested-by: Chia-Lin Kao (AceLan) Tested-by: Geert Uytterhoeven Reviewed-by: Martin K. Petersen --- drivers/ata/libata-core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 8e326a445765..de661780a31e 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -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);