Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp3336941imc; Wed, 13 Mar 2019 15:22:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqyPUOd5Yd7OIP+Ug+4UnxMsxnJxzyQNXaEmNS1Ch1bLAsBiwFVOHo9wm/LpQDJidAkeJc6Q X-Received: by 2002:a17:902:ab8f:: with SMTP id f15mr47927675plr.218.1552515744273; Wed, 13 Mar 2019 15:22:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552515744; cv=none; d=google.com; s=arc-20160816; b=gLkXw8Lvl+hIiBynyKarXVEEOnUfDMKqXnyvqGnG0Rf+Rhk/bl9EG3pPeJMAkYoHRQ X9e24UgZ7NzC8Qq7FReBfgjpQHhURKqfhlLZ0l15MTP0T95ATQwPBww6Gy1EYkOMt6sF Su7/fvjsdWclhPaWu88C/W3HQwTJ8+TMyHGIv+qT9WtI9+z+HhOybGU4ILeesSZHjDAz 2q7RhdhW5ty2XPMhcq1aBHeY4rhXX32gl/ROq1v/fSyzd0qrRijnNJ2fYGmzx/ISCaGJ uDYGHAtkIy9uEcuN47giDO8MUyxczYWsgxnysOkcfPfoOblZW2qjY8wLMrTAEqE2o8sX teDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=N/8bTN+wgMZray1e0uHhmLK00Ub7CbzrJhnIjb/FwiA=; b=V/95GKAgTm/9NvupH1n2ExbeobtnYrzkllB2yRSO6URH2pF6Dx8roFtgv58ZIq+gX+ ApseLFvbjoxpGRtoHU4OZSPEQU0/9YOWfTndp1g7KUOJs8OJOQb9ueq/3poNyC9aVxdg EmUBDlJrIMXTANvlSvO0afLju0AcHFGEv0Klf3TJ0IOGo5bkObh5YwuPJ81lgIF4D3YC uiN2zW/B8I7QjyoWP/ibXrnIr0ZW4kmONM4HDzkU6oZi3mIbZetUwO2aiRWgLAMjfyQZ ssjiqPZYvRWR8XKEoeV9INJ3upLFhgqQdHlGuGM8MZDJl3VVo/GI0i5JrFb/Qsf3fPCe Pd5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Vxzpb319; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y14si11467412plr.78.2019.03.13.15.22.08; Wed, 13 Mar 2019 15:22:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Vxzpb319; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726954AbfCMWVf (ORCPT + 99 others); Wed, 13 Mar 2019 18:21:35 -0400 Received: from mail-vk1-f201.google.com ([209.85.221.201]:47643 "EHLO mail-vk1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726568AbfCMWVe (ORCPT ); Wed, 13 Mar 2019 18:21:34 -0400 Received: by mail-vk1-f201.google.com with SMTP id y132so1243737vkd.14 for ; Wed, 13 Mar 2019 15:21:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=N/8bTN+wgMZray1e0uHhmLK00Ub7CbzrJhnIjb/FwiA=; b=Vxzpb3191e4PQi2AYMtPoN/HMgrcaSIhwwScfsk+zKFIN3fQpNuTicDdGOY/jDNG7+ YFcZujD7dAf0Acp40m2RWE77X46VtQczzObma4M/gBJj3mFIaF1EvCJkn6A931iBu30u yW6oFSDCnawGeNb5UWL9RMbvoao8oosxUNZ27SCZqFiUmHYXfzEqeKh8wAVUIoV4QK2U w+CRh05kbtuRpGpP1bLILORLWJID9swGib3pZvHlDjuXMkATOrN2CzQBxVVsHEmIcWrZ 2TbyTqJANJUIozahl66CeQKeuu4j9tasPVuw8L63GiISC4IPA+EwivVerCMgwc7QSK3/ Zx4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=N/8bTN+wgMZray1e0uHhmLK00Ub7CbzrJhnIjb/FwiA=; b=L1ndsQTz1I3RgU221ACgnObaXsorAN2B/PXmMPtLvkEZPjYj62CjrwnQJ/DA5J6S4P DioILeQ5TvsoL/ufpdKYIAb9EOW0xlcy/VNG2pFPYFUmAGwI66RcVzDhV3Ua2Behsxuj DT2PTGxZhD4c6LS/L/593EYIrzKjekw899Hp86PrjcGChYEwFh8ch0uAx1pZwLkcTOHA bU2/C1q+Qd5sP+IJJgHSBpU8aYBgDNoLnMsfV4YiSwxBioDtfuuEcNEC8p9sglpvEzNI 1gZ92BMU6w1ytdI/sp31FMadCccX81Xkm3KFtlT3hvBYLx2wRj8AGjLG0dH8tuvEwjQu lDPg== X-Gm-Message-State: APjAAAUOOwSPQgGUJSCGyhh+Adj/XMBEyEx3HKFFc/f4/Xyr4mQnEHsP a4kO45cv+UJGIhCGkn3cLAUOLLc82wtZ X-Received: by 2002:ab0:22ce:: with SMTP id z14mr29223600uam.20.1552515693312; Wed, 13 Mar 2019 15:21:33 -0700 (PDT) Date: Wed, 13 Mar 2019 15:21:24 -0700 In-Reply-To: <20190313222124.229371-1-rajatja@google.com> Message-Id: <20190313222124.229371-2-rajatja@google.com> Mime-Version: 1.0 References: <20190313222124.229371-1-rajatja@google.com> X-Mailer: git-send-email 2.21.0.360.g471c308f928-goog Subject: [PATCH 2/2] platform/x86: intel_pmc_core: Allow to dump debug registers on S0ix failure From: Rajat Jain To: Rajneesh Bhardwaj , Vishwanath Somayaji , Darren Hart , Andy Shevchenko , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Rajat Jain , furquan@google.com, evgreen@google.com, rajatxjain@gmail.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a module parameter which when enabled, will check on resume, if the last S0ix attempt was successful. If not, the driver would provide helpful debug information (which gets latched during the failed suspend attempt) to debug the S0ix failure. This information is very useful to debug S0ix failures. Specially since the latched debug information will be lost (over-written) if the system attempts to go into runtime (or imminent) S0ix again after that failed suspend attempt. Signed-off-by: Rajat Jain --- drivers/platform/x86/intel_pmc_core.c | 86 +++++++++++++++++++++++++++ drivers/platform/x86/intel_pmc_core.h | 7 +++ 2 files changed, 93 insertions(+) diff --git a/drivers/platform/x86/intel_pmc_core.c b/drivers/platform/x86/intel_pmc_core.c index 55578d07610c..b1f4405a27ce 100644 --- a/drivers/platform/x86/intel_pmc_core.c +++ b/drivers/platform/x86/intel_pmc_core.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -890,9 +891,94 @@ static int pmc_core_remove(struct platform_device *pdev) return 0; } +#ifdef CONFIG_PM_SLEEP + +static bool warn_on_s0ix_failures; +module_param(warn_on_s0ix_failures, bool, 0644); +MODULE_PARM_DESC(warn_on_s0ix_failures, "Check and warn for S0ix failures"); + +static int pmc_core_suspend(struct device *dev) +{ + struct pmc_dev *pmcdev = dev_get_drvdata(dev); + + /* Save PC10 and S0ix residency for checking later */ + if (warn_on_s0ix_failures && + !rdmsrl_safe(MSR_PKG_C10_RESIDENCY, &pmcdev->pc10_counter) && + !pmc_core_dev_state_get(pmcdev, &pmcdev->s0ix_counter)) + pmcdev->check_counters = true; + else + pmcdev->check_counters = false; + + return 0; +} + +static inline bool pc10_failed(struct pmc_dev *pmcdev) +{ + u64 pc10_counter; + + if (!rdmsrl_safe(MSR_PKG_C10_RESIDENCY, &pc10_counter) && + pc10_counter == pmcdev->pc10_counter) + return true; + else + return false; +} + +static inline bool s0ix_failed(struct pmc_dev *pmcdev) +{ + u64 s0ix_counter; + + if (!pmc_core_dev_state_get(pmcdev, &s0ix_counter) && + s0ix_counter == pmcdev->s0ix_counter) + return true; + else + return false; +} + +static int pmc_core_resume(struct device *dev) +{ + struct pmc_dev *pmcdev = dev_get_drvdata(dev); + + if (!pmcdev->check_counters) + return 0; + + if (pc10_failed(pmcdev)) { + dev_info(dev, "PC10 entry had failed (PC10 cnt=0x%llx)\n", + pmcdev->pc10_counter); + } else if (s0ix_failed(pmcdev)) { + + const struct pmc_bit_map **maps = pmcdev->map->slps0_dbg_maps; + const struct pmc_bit_map *map; + int offset = pmcdev->map->slps0_dbg_offset; + u32 data; + + dev_warn(dev, "S0ix entry had failed (S0ix cnt=%llu)\n", + pmcdev->s0ix_counter); + while (*maps) { + map = *maps; + data = pmc_core_reg_read(pmcdev, offset); + offset += 4; + while (map->name) { + dev_warn(dev, "SLP_S0_DBG: %-32s\tState: %s\n", + map->name, + data & map->bit_mask ? "Yes" : "No"); + ++map; + } + ++maps; + } + } + return 0; +} + +#endif + +const struct dev_pm_ops pmc_core_pm_ops = { + SET_LATE_SYSTEM_SLEEP_PM_OPS(pmc_core_suspend, pmc_core_resume) +}; + static struct platform_driver pmc_core_driver = { .driver = { .name = "pmc_core", + .pm = &pmc_core_pm_ops }, .probe = pmc_core_probe, .remove = pmc_core_remove, diff --git a/drivers/platform/x86/intel_pmc_core.h b/drivers/platform/x86/intel_pmc_core.h index 88d9c0653a5f..fdee5772e532 100644 --- a/drivers/platform/x86/intel_pmc_core.h +++ b/drivers/platform/x86/intel_pmc_core.h @@ -241,6 +241,9 @@ struct pmc_reg_map { * @pmc_xram_read_bit: flag to indicate whether PMC XRAM shadow registers * used to read MPHY PG and PLL status are available * @mutex_lock: mutex to complete one transcation + * @check_counters: On resume, check if counters are getting incremented + * @pc10_counter: PC10 residency counter + * @s0ix_counter: S0ix residency (step adjusted) * * pmc_dev contains info about power management controller device. */ @@ -253,6 +256,10 @@ struct pmc_dev { #endif /* CONFIG_DEBUG_FS */ int pmc_xram_read_bit; struct mutex lock; /* generic mutex lock for PMC Core */ + + bool check_counters; /* Check for counter increments on resume */ + u64 pc10_counter; + u64 s0ix_counter; }; #endif /* PMC_CORE_H */ -- 2.21.0.360.g471c308f928-goog