Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1426612AbdDUXTl (ORCPT ); Fri, 21 Apr 2017 19:19:41 -0400 Received: from mail.kernel.org ([198.145.29.136]:60278 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1425440AbdDUXTb (ORCPT ); Fri, 21 Apr 2017 19:19:31 -0400 From: Andy Lutomirski To: Jens Axboe , Christoph Hellwig , Sagi Grimberg , Keith Busch Cc: "linux-kernel@vger.kernel.org" , Kai-Heng Feng , linux-nvme , Andy Lutomirski Subject: [PATCH 2/3] nvme: Display raw APST configuration via DYNAMIC_DEBUG Date: Fri, 21 Apr 2017 16:19:23 -0700 Message-Id: <54e956746d3df270f0c99010909422d919989b0e.1492816561.git.luto@kernel.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1623 Lines: 57 Debugging APST is currently a bit of a pain. This gives optional simple log messages that describe the APST state. The easiest way to use this is probably with the nvme_core.dyndbg=+p module parameter. Signed-off-by: Andy Lutomirski --- drivers/nvme/host/core.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index b0c692a14e9b..05ba4f8bb73b 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -1278,6 +1278,8 @@ static void nvme_configure_apst(struct nvme_ctrl *ctrl) unsigned apste; struct nvme_feat_auto_pst *table; + u64 max_lat_us = 0; + int max_ps = -1; int ret; /* @@ -1299,6 +1301,7 @@ static void nvme_configure_apst(struct nvme_ctrl *ctrl) if (ctrl->ps_max_latency_us == 0) { /* Turn off APST. */ apste = 0; + dev_dbg(ctrl->device, "APST disabled\n"); } else { __le64 target = cpu_to_le64(0); int state; @@ -1348,9 +1351,22 @@ static void nvme_configure_apst(struct nvme_ctrl *ctrl) target = cpu_to_le64((state << 3) | (transition_ms << 8)); + + if (max_ps == -1) + max_ps = state; + + if (total_latency_us > max_lat_us) + max_lat_us = total_latency_us; } apste = 1; + + if (max_ps == -1) { + dev_dbg(ctrl->device, "APST enabled but no non-operational states are available\n"); + } else { + dev_dbg(ctrl->device, "APST enabled: max PS = %d, max round-trip latency = %lluus, table = %*phN\n", + max_ps, max_lat_us, (int)sizeof(*table), table); + } } ret = nvme_set_features(ctrl, NVME_FEAT_AUTO_PST, apste, -- 2.9.3