From patchwork Fri Sep 15 08:14:58 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: 1834754 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=fOHIwpDX; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2620:137:e000::1:20; helo=out1.vger.email; envelope-from=linux-ide-owner@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by legolas.ozlabs.org (Postfix) with ESMTP id 4Rn6hf5Qb7z1ypK for ; Fri, 15 Sep 2023 18:25:54 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230454AbjIOIZ5 (ORCPT ); Fri, 15 Sep 2023 04:25:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232870AbjIOIZx (ORCPT ); Fri, 15 Sep 2023 04:25:53 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC6B52D4A; Fri, 15 Sep 2023 01:23:40 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 88CF7C433AD; Fri, 15 Sep 2023 08:15:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694765736; bh=KJoyWvVWhsIz4VVso+iFvB6Gta5M3O5M/mkqnLKFAMo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fOHIwpDXHQeN0cKfb8Tg7KzXDw7VargqVzd76etLNp6rMvtOt4i2g3/YMGoAEumdY H9CGFmkxHKto93ya71zo1m/wxHsnmwBio2Bi+w+UeCKMozQqGLfVgcn2ML/BMjnQLC KWz1gWzzyDbyIxlYHPu68gwgO8tnU0bUTyoZsMqB+0BAYYs7qCaK3kdVW40nFzX0rB LU2ZdfhEGvvA9dwg96a2eD6LVbSGqWMWWOQPFVmlAUh/K8IodMXob//uCJfs49+CIG QqKGlHiR9UDK+qo/aJlEYJnwRysr0j4UKC6H7x0mzJ1qV32cocsDHmeenUKINj7Y70 U2yUuFUM77vIw== 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 v3 14/23] ata: libata-core: Synchronize ata_port_detach() with hotplug Date: Fri, 15 Sep 2023 17:14:58 +0900 Message-ID: <20230915081507.761711-15-dlemoal@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230915081507.761711-1-dlemoal@kernel.org> References: <20230915081507.761711-1-dlemoal@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-ide@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) --- 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 8d1949302a8a..9f05ad187c9e 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -6069,6 +6069,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); @@ -6133,11 +6136,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);