From patchwork Fri Feb 16 11:20:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Cassel X-Patchwork-Id: 1900000 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=gZ60BuJG; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:4601:e00::3; helo=am.mirrors.kernel.org; envelope-from=linux-ide+bounces-568-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from am.mirrors.kernel.org (am.mirrors.kernel.org [IPv6:2604:1380:4601:e00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TbqH7716dz23hm for ; Fri, 16 Feb 2024 22:20:35 +1100 (AEDT) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 8D6C41F22890 for ; Fri, 16 Feb 2024 11:20:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 879AA612CC; Fri, 16 Feb 2024 11:20:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gZ60BuJG" X-Original-To: linux-ide@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 442B460BAD; Fri, 16 Feb 2024 11:20:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708082419; cv=none; b=TDZKYUSaaFyxo9xHPlfI46gMSK8Zo+2Te4WUFRjsBjzpuuFjbwNY5pCZpOeDs9DJbizMhfpq20xoncaXsxG/HC10xsaY6gA8IE+bVEB5aV5hbvd87Ys+QLGDdlpKiOHlncVfmlx26pYl7nTHnxFqQcPA7bepn6qeXgSFNYVG8HU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708082419; c=relaxed/simple; bh=VHv3IYjlHR6MUnfBc57C98lM3wMHgx0zJpPwl1b5C0Q=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=WQG4U0vsdgOsYvv3nFQH/g1znJCui0LrlMLF/LHJ4KFnUP56pcNN8JR1KOJb444GS/qEqtqrXtritHvl/0APIkHTkFGS2fuvbiYs54n0VVM2QmPevnuZcrYpKnlpJNcQO9VyywyD15x7NehQq2frnnjA5vBAtMUOo8xOk7DN0c8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gZ60BuJG; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 080C5C433F1; Fri, 16 Feb 2024 11:20:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708082418; bh=VHv3IYjlHR6MUnfBc57C98lM3wMHgx0zJpPwl1b5C0Q=; h=From:To:Cc:Subject:Date:From; b=gZ60BuJG169m3E1IZ7ML64F+uRom6HmsZtlRer3uqK7WqWJ2+dVoPcUpbFjCFFfGl mMuYVxSELFmwv0Lg2QMgcqvdl0JOansiVbg69U349nkxaUzUQLiz+CPgIk1VuQ0xd4 u8LYksz9+KfqwLN95UiLuXjekq7xDyIsbdhaH06Y4m5UzIcgUlLVYzb9LL+EbjI3XA hstuFIzojYR6SZEYg1tyKhLPsdo//eKxVHpoKZ1N5/QdnjqJBcOElcToe0pouqjaYh Mk6ERg5jACqPfSCFVATKzDTmW59upV5ZKfVjaFSxD/mn3THiOJ5oRujYQr7/tFWScA k/bK96BOid4nw== From: Niklas Cassel To: Damien Le Moal , Niklas Cassel Cc: stable@vger.kernel.org, Niklas Cassel , linux-ide@vger.kernel.org Subject: [PATCH] ata: libata-core: Do not call ata_dev_power_set_standby() twice Date: Fri, 16 Feb 2024 12:20:07 +0100 Message-ID: <20240216112008.1112538-1-cassel@kernel.org> X-Mailer: git-send-email 2.43.1 Precedence: bulk X-Mailing-List: linux-ide@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Damien Le Moal For regular system shutdown, ata_dev_power_set_standby() will be executed twice: once the scsi device is removed and another when ata_pci_shutdown_one() executes and EH completes unloading the devices. Make the second call to ata_dev_power_set_standby() do nothing by using ata_dev_power_is_active() and return if the device is already in standby. Fixes: 2da4c5e24e86 ("ata: libata-core: Improve ata_dev_power_set_active()") Cc: stable@vger.kernel.org Signed-off-by: Damien Le Moal Signed-off-by: Niklas Cassel --- This fix was originally part of patch that contained both a fix and a revert in a single patch: https://lore.kernel.org/linux-ide/20240111115123.1258422-3-dlemoal@kernel.org/ This patch contains the only the fix (as it is valid even without the revert), without the revert. Updated the Fixes tag to point to a more appropriate commit, since we no longer revert any code. drivers/ata/libata-core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index d9f80f4f70f5..af2334bc806d 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -85,6 +85,7 @@ static unsigned int ata_dev_init_params(struct ata_device *dev, static unsigned int ata_dev_set_xfermode(struct ata_device *dev); static void ata_dev_xfermask(struct ata_device *dev); static unsigned long ata_dev_blacklisted(const struct ata_device *dev); +static bool ata_dev_power_is_active(struct ata_device *dev); atomic_t ata_print_id = ATOMIC_INIT(0); @@ -2017,8 +2018,9 @@ void ata_dev_power_set_standby(struct ata_device *dev) struct ata_taskfile tf; unsigned int err_mask; - /* If the device is already sleeping, do nothing. */ - if (dev->flags & ATA_DFLAG_SLEEPING) + /* If the device is already sleeping or in standby, do nothing. */ + if ((dev->flags & ATA_DFLAG_SLEEPING) || + !ata_dev_power_is_active(dev)) return; /*