Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp700069rdb; Fri, 2 Feb 2024 00:51:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IHOO6Qz6yMwWupiSz/WlpSOy+10WRHLOvk6BftfZzCVFQO+tEd9XFBEi+gj/YLODdxDGp8F X-Received: by 2002:a05:6214:29eb:b0:686:9f99:97de with SMTP id jv11-20020a05621429eb00b006869f9997demr9909664qvb.13.1706863868738; Fri, 02 Feb 2024 00:51:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706863868; cv=pass; d=google.com; s=arc-20160816; b=eO/4xNAfwoc06tL96hUn9RJncGZ4qGxZuHNR+hPy3++SV8qbOpTLiDM/UaE3mj4G1V aa264GdF1HBHxVTgnWLRqje9hk9GP69Wc0RNNxPLJ0hRcE/uiJKPwZfgCXM3LG/kuM2W 2n6J4hKYPTGPuMCv6uw4yrZJdeiaJT39AsF6lqaTnHDhisHYWIu+HobLVrM72gt4zuTU hMWy1BSjEalsJT6CK0ezZmhMfW+6CQBRwMDcWCBS3h6fOFQop/1TeDob9eJzArss8Kt5 KCBleG7pP08Nj3MFNG2uOKvidj7JYQKO2vIOxgAyO/gbfJ0pFV5oFcGiJhpY8JXqQ9k3 LTvg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=VIPMr9gZ2ntFdhqS2A/x2RHH72S8+R3tOzCoETsh9oA=; fh=QY5CjwZAlI1madOEZ8BraXwvm2Q4Blsff/xVfB1zMrM=; b=KaORa22V0nQ/IOlpG/UkmXuCKxyCJ5HpJV/BdkuN63nms5PIlZIWSuy7vPtPPVzRWD Dn8u8MBWY0fSXscKpcgDu3ozxjTtTWP1Xy3WTD3Vtpv14UZcV2igQ7jg6FsRHg1fpxjc 9aDGHdSoci2ETZFO7jeQJ32nbqksYme6Rmx36UsPjxCKkCZ8iTjY4bQFeE43IsJA8ueI mVfprxmq/t3IrkMVVZNR1T+TIunjEXaD35J2uR75YMDdlZrJX/u1y6ocGBcwkUt4t7We np3tyvZA84x8cs3lXDxioyU3xdmCD57gqvEOu19et13EhpC1N2vBgmi3/gB6Du7V3f9I GJDA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@endlessos.org header.s=google header.b="Yf+voq//"; arc=pass (i=1 spf=pass spfdomain=endlessos.org dkim=pass dkdomain=endlessos.org dmarc=pass fromdomain=endlessos.org); spf=pass (google.com: domain of linux-kernel+bounces-49506-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49506-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=endlessos.org X-Forwarded-Encrypted: i=1; AJvYcCXxvQlS45a/QTUiMVBcOk4SaJ2F1ZDqtX5tI10NqXWRdXh0JT9caAbvU7C2g6hbS7U+quLYTyq/eLxKPlCUe4C+Ca0uHNpifPHKq8cGnQ== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id g5-20020a0cf845000000b0068c81aae324si1488321qvo.418.2024.02.02.00.51.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 00:51:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-49506-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@endlessos.org header.s=google header.b="Yf+voq//"; arc=pass (i=1 spf=pass spfdomain=endlessos.org dkim=pass dkdomain=endlessos.org dmarc=pass fromdomain=endlessos.org); spf=pass (google.com: domain of linux-kernel+bounces-49506-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49506-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=endlessos.org 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 5532B1C2721F for ; Fri, 2 Feb 2024 08:50:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3B1595FEFF; Fri, 2 Feb 2024 08:49:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=endlessos.org header.i=@endlessos.org header.b="Yf+voq//" Received: from mail-yb1-f172.google.com (mail-yb1-f172.google.com [209.85.219.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 35D875FDBD for ; Fri, 2 Feb 2024 08:49:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706863780; cv=none; b=QxtTmj9Y9CtyN5MHOMoZMtZkgrFzAIsD8O9tMIkjpFKW9itTmK6jbtHrvj8ib6Ef+dRPKPXXXpGJ+ofR11RtWtqWANLcLSA5zxibR6Let/f6gsFOoeqR3QOrcHSzraMFNvcAIwkmKsVUSK52hMcRSQwQQ7kT5voSWpgZRpMrNaY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706863780; c=relaxed/simple; bh=s5g5tND4VncSJJnpgai+1STmfwY17PR0zOkvpBvqkBI=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=brDcjs4vtZG/Grj76EKtUQiy1YS97gCWEHsveBvtjJoxL6YUaLGg3fA/iRVlNmpK6iXYB1rsAQIMt6Qp9Fd+uLyb2MECxPdPiWIbaMrHHJ/0JMeF8iWIYej+cjlcgZYPznSDeEZC9raU9VA/GIuu13PDDdydHrjuLyExWOJVoY4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=endlessos.org; spf=pass smtp.mailfrom=endlessos.org; dkim=pass (2048-bit key) header.d=endlessos.org header.i=@endlessos.org header.b=Yf+voq//; arc=none smtp.client-ip=209.85.219.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=endlessos.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=endlessos.org Received: by mail-yb1-f172.google.com with SMTP id 3f1490d57ef6-dc6af9a988eso1638510276.0 for ; Fri, 02 Feb 2024 00:49:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=endlessos.org; s=google; t=1706863776; x=1707468576; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=VIPMr9gZ2ntFdhqS2A/x2RHH72S8+R3tOzCoETsh9oA=; b=Yf+voq//sAGg3WTgaevPYQy0hb2RJg9y1SmIIKJU7lM4x11x609ILkQt1cu2oHjB11 Z2byK6cWb22h0AieGDxN6hJd5KWDgPQJA+yE1LuhaRujjc9Buj/NH40pWddd0Jbk4daC dgXn/5d2kptmSvpFMFiUH//ege/HU9nA4ebB3WOCkxIMXC5K2+ABZ2IDtAbc5OGsTP8O 3I2bjeCZZCM6vKOVnLHBhJsM667LvF2IgOHAtu0aX9JC9r5/xInNL1adptRErMzJh/Nb jxGpHQV4QdGuTlVnuV4KFw3gYHt5vFHRn7YspplLO8TRUpzmPrD9kbnDVEw07Djaa636 ZlCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706863776; x=1707468576; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VIPMr9gZ2ntFdhqS2A/x2RHH72S8+R3tOzCoETsh9oA=; b=Ustq5w8hhzYl+BhfDY3G3Dgx8KT+D657ABYepei4udMAFLqxaIL2rkMUfYgkjYsHlh mQXNnJMBP29dsYZzUSCYBsnbWYBcseb7DkqQSA/Lx0t3oprLVbUwLneWs+K+vEuvqiaw gjgXESZZWoajla9MIU/W7VBaTsuQBUi9Sha1jfgJ4Dk3a4AtpNU3ZwHQ2a16fh3cFndC w/lxt0GT6sgc8uNYX3VrOfSWfNlwHtf8+b/XnBE91fQJItpnh8EOlAwn1JG2Clr78Ixq 3J/rvUsNWVSumFtQ3zRsr/dNZCsOwjwKZSoyExDZQwKEWrTRaSsx1Skb10MA9lk7U9jQ oZJQ== X-Gm-Message-State: AOJu0Yx5old1j0wJDrXBMF9isJjw6aOGiKNGDf1WJ7ahHKRMfOMe8oXj Cf4RvDsQwAflqlNKjTQHvU3QAOr03kdE3nvsZdv9TNcAWxvkQowZLKG0oZPGmoFkwQS0f+sNTV9 buhr2m+MCLTcL3XeuYFi6CJ/3meh9u5vOsM0OfojuXd7RXcHmV9M= X-Received: by 2002:a25:c782:0:b0:dc2:2f4b:c9d8 with SMTP id w124-20020a25c782000000b00dc22f4bc9d8mr7270958ybe.16.1706863776050; Fri, 02 Feb 2024 00:49:36 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240130095933.14158-1-jhp@endlessos.org> <20240130101335.GU2543524@black.fi.intel.com> In-Reply-To: From: Jian-Hong Pan Date: Fri, 2 Feb 2024 16:49:00 +0800 Message-ID: Subject: Re: [PATCH 1/2] ata: ahci: Add force LPM policy quirk for ASUS B1400CEAE To: Niklas Cassel Cc: Daniel Drake , Vitalii Solomonov , Mika Westerberg , David Box , Damien Le Moal , Nirmal Patel , Jonathan Derrick , linux-ide@vger.kernel.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux@endlessos.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Niklas Cassel =E6=96=BC 2024=E5=B9=B42=E6=9C=881=E6=97= =A5 =E9=80=B1=E5=9B=9B =E4=B8=8B=E5=8D=8811:01=E5=AF=AB=E9=81=93=EF=BC=9A > > On Wed, Jan 31, 2024 at 11:43:59PM +0100, Niklas Cassel wrote: > > On Wed, Jan 31, 2024 at 07:08:12AM -0400, Daniel Drake wrote: > > (snip) > > > In libata we perform a reset of the port at boot, see: > > libata-sata.c:sata_link_hardreset() > > after writing to SControl, we call > > libata-core.c:ata_wait_ready() that will poll for the port being ready > > by calling the check_ready callback. > > For AHCI, this callback funcion is set to: > > libahci.c:ahci_check_ready(). > > > > A reset should take the device out of deep power state and should be > > sufficient to establish a connection (and that also seems to be the > > case when not using Intel VMD). > > > > However, if you want to debug, I would start by adding prints to > > libata-sata.c:sata_link_hardreset() > > libata-core.c:ata_wait_ready() > > libahci.c:ahci_check_ready(). > > FWIW, this will dump SStatus.DET every time the check_ready callback func= tion > (ahci_check_ready()) is called: > > > diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c > index 1a63200ea437..0467e150601e 100644 > --- a/drivers/ata/libahci.c > +++ b/drivers/ata/libahci.c > @@ -1533,6 +1533,12 @@ int ahci_check_ready(struct ata_link *link) > { > void __iomem *port_mmio =3D ahci_port_base(link->ap); > u8 status =3D readl(port_mmio + PORT_TFDATA) & 0xFF; > + u32 cur =3D 0; > + > + sata_scr_read(link, SCR_STATUS, &cur); > + > + ata_link_info(link, "BUSY ? %d (status: %#x) SStatus.DET: %#x\n", > + status & ATA_BUSY, status, cur & 0xf); > > return ata_check_ready(status); > } I think I can join the test based on kernel v6.8-rc2, too. The original ASUS B1400CEAE has only one NVMe SSD. I prepare the patch ("ata: ahci: Add force LPM policy quirk for ASUS B1400CEAE") to fix the power consumption issue for s2idle with enabled VMD. The patch is a quirk limiting ASUS B1400CEAE only, not generic for the SATA controller [8086:a0d3]. Then, I install another SATA HDD into ASUS B1400CEAE for test. The SATA HDD shows up and works. $ dmesg | grep SATA [ 0.785120] ahci 10000:e0:17.0: AHCI 0001.0301 32 slots 1 ports 6 Gbps 0x1 impl SATA mode [ 0.785269] ata1: SATA max UDMA/133 abar m2048@0x76102000 port 0x76102100 irq 144 lpm-pol 3 [ 1.096684] ata1: SATA link up 6.0 Gbps (SStatus 133 SControl 300) However, if I simply revert the commit 6210038aeaf4 ("ata: ahci: Revert "ata: ahci: Add Tiger Lake UP{3,4} AHCI controller"") (fix the conflict, of course), then the SATA HDD disappears!!? Both CONFIG_SATA_MOBILE_LPM_POLICY=3D3 and 0 can reproduce the issue. $ dmesg | grep SATA [ 0.783211] ahci 10000:e0:17.0: AHCI 0001.0301 32 slots 1 ports 6 Gbps 0x1 impl SATA mode [ 0.783399] ata1: SATA max UDMA/133 abar m2048@0x76102000 port 0x76102100 irq 144 lpm-pol 3 [ 1.096685] ata1: SATA link down (SStatus 4 SControl 300) Here is the dmesg of reverting ("ata: ahci: Revert "ata: ahci: Add Tiger Lake UP{3,4} AHCI controller"") https://bugzilla.kernel.org/show_bug.cgi?id=3D217114#c27 The code already includes the debug message in ahci_check_ready() from Niklas. However, the dmesg does not show the "BUSY ? ..." from ahci_check_ready(). From these scenarios mentioned above, they all apply LPM policy to the SATA controller [8086:a0d3]. But, they apply LPM policy at different time: * The patch ("ata: ahci: Add force LPM policy quirk for ASUS B1400CEAE") applies LPM policy in early ahci_init_one(), which is the probe callback. * Reverting 6210038aeaf4 ("ata: ahci: Revert "ata: ahci: Add Tiger Lake UP{3,4} AHCI controller"") applies LPM policy via "ahci_pci_tbl" table. Jian-Hong Pan