From patchwork Thu Jan 4 22:39:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phillip Susi X-Patchwork-Id: 1882663 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:40f1:3f00::1; helo=sy.mirrors.kernel.org; envelope-from=linux-ide+bounces-139-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org [IPv6:2604:1380:40f1:3f00::1]) (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 4T5hPL3T2hz23dn for ; Fri, 5 Jan 2024 09:40:22 +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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 40E60B2375A for ; Thu, 4 Jan 2024 22:40:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CD1062CCB4; Thu, 4 Jan 2024 22:40:19 +0000 (UTC) X-Original-To: linux-ide@vger.kernel.org Received: from vps.thesusis.net (vps.thesusis.net [34.202.238.73]) (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 647182CCD1 for ; Thu, 4 Jan 2024 22:40:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=thesusis.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=thesusis.net Received: by vps.thesusis.net (Postfix, from userid 1000) id 94A2D151D5F; Thu, 4 Jan 2024 17:40:17 -0500 (EST) From: Phillip Susi To: Damien Le Moal Cc: linux-ide@vger.kernel.org, Phillip Susi Subject: [PATCH 3/4] libata: avoid waking disk for several commands Date: Thu, 4 Jan 2024 17:39:39 -0500 Message-Id: <20240104223940.339290-3-phill@thesusis.net> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240104223940.339290-1-phill@thesusis.net> References: <87y1d5kxcc.fsf@vps.thesusis.net> <20240104223940.339290-1-phill@thesusis.net> Precedence: bulk X-Mailing-List: linux-ide@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 When a disk is in SLEEP mode it can not respond to any commands. Instead of waking up the sleeping disk, fake the commands. The commands include: CHECK POWER FLUSH CACHE SLEEP STANDBY IMMEDIATE IDENTIFY If we konw the disk is sleeping, we don't need to wake it up to to find out if it is in standby, so just pretend it is in standby. While alseep, there's no dirty pages in the cache, so there's no need to flush it. There's no point in waking a disk from sleep just to put it back to sleep. We also have a cache of the IDENTIFY information so just return that instead of waking the disk. --- drivers/ata/libata-core.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 1244da8f77e2..d9e889fa2881 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -5045,6 +5045,22 @@ void ata_qc_issue(struct ata_queued_cmd *qc) /* if device is sleeping, schedule reset and abort the link */ if (unlikely(qc->dev->flags & ATA_DFLAG_SLEEPING)) { + if (unlikely(qc->tf.command == ATA_CMD_CHK_POWER || + qc->tf.command == ATA_CMD_SLEEP || + qc->tf.command == ATA_CMD_FLUSH || + qc->tf.command == ATA_CMD_FLUSH_EXT || + qc->tf.command == ATA_CMD_STANDBYNOW1 || + (qc->tf.command == ATA_CMD_ID_ATA && + !ata_tag_internal(qc->tag)))) + { + /* fake reply to avoid waking drive */ + qc->flags |= ATA_QCFLAG_RTF_FILLED; + qc->result_tf.nsect = 0; + if (qc->tf.command == ATA_CMD_ID_ATA) + sg_copy_from_buffer(qc->sg, 1, qc->dev->id, 2 * ATA_ID_WORDS); + ata_qc_complete(qc); + return; + } link->eh_info.action |= ATA_EH_RESET; ata_ehi_push_desc(&link->eh_info, "waking up from sleep"); ata_link_abort(link);