Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp69384img; Tue, 19 Mar 2019 18:07:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqw/NBPPcZsN5jE9Q1/ntb112Qx6UxoFz0pjjiBn4F53105TSwtNsakHzO7T5yvVEn4tdE7/ X-Received: by 2002:a63:1014:: with SMTP id f20mr4697513pgl.293.1553044026266; Tue, 19 Mar 2019 18:07:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553044026; cv=none; d=google.com; s=arc-20160816; b=ZNJf651bmUVwn96tsbBHzJ/8R4ScnJTV1KPcGdM60sUf1mwWHZqXq1x6tNnLvbQooX nte0qii7oG7a5Zje/uFEjT24W4XvZh2lCuNj52eVtK6shHK/uqE1+i25DrNX7tv3Shfg c5ExIxZ2/hB8Qr4tMEAtPW8gQnWlKBFRCifSO6jtwzCP+qJ6Gis12dtcVltkDkL7xfHw 4h2RS23b/JvScsrF7cPJaWicJcWdzcccSPy1hAcO/mW3NWlWJyoYPntPkKYPhcsJzB7n zIfX/6z4fulzbjSqsdChRZNsmxtOqUbKHKg2d7yhj2RjJwZ3a4MF0gTDAk3HJIPXVE5r PQRw== 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=FjGKF+9fQR3oX5+16IJIymH9iLuHR5HxuJmit6BGji4=; b=UnAvvHWxlnxMwaWuoCX8l7CGo6oIw/LFUG5XJvN2nAcGiQI+qR4yTdtg7EYvPsEURM 0EEU2uXjmqa7OzLj2o4r2sptu5GsjfkE+Z0Zz/Fm0yB7fY+nJC7KxBCK6ElH6m+Y/7rb JXptk9QMLi4sMPfTcnphnFOq+kBrVOwge0vBXC47xMgbFliNCxSYJSCEM5sWnzwaoSoT 9BKJzYR/OoCPnqKZqh1nyuj2bKYwphJDxLwlCF2DqNQ0cGBK6iJ9JB5HPwo3EOC57/aw +uaqxi+b6ZF/6n2BRBNiR32ml7/8I8ZiImhUqePUq1hDWd44UtuoKJ0nZUwSJjP8390B MN/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="gnl9Jl8/"; 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 c11si351640pfn.233.2019.03.19.18.06.50; Tue, 19 Mar 2019 18:07:06 -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="gnl9Jl8/"; 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 S1727436AbfCTBEl (ORCPT + 99 others); Tue, 19 Mar 2019 21:04:41 -0400 Received: from mail-vk1-f201.google.com ([209.85.221.201]:53901 "EHLO mail-vk1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727406AbfCTBEk (ORCPT ); Tue, 19 Mar 2019 21:04:40 -0400 Received: by mail-vk1-f201.google.com with SMTP id 5so362125vkg.20 for ; Tue, 19 Mar 2019 18:04:39 -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=FjGKF+9fQR3oX5+16IJIymH9iLuHR5HxuJmit6BGji4=; b=gnl9Jl8/gtPJurfj/iCHxxyc0bx2lUu/PcCqjIDRhZbnYRgLk+8zyS/8KrkkKblMHd v2EibdcN9ZeLZgb9awwOBj+Df9NpnszHMJm097kawu1oI0oYE/mSOhX7yn0QrrG07rQU AKhiUzCFXPspxqyKJAotRQgsxfPV7eK5bzz52paQZiSzFo9E1GPj2Gch58WNYgydUSiJ oy9A/TpjHZhv3URruRlV554Xd7AqRHiemm2N6AyfqdQQB2JmTpPE0G7U0xYVr0xwdMc6 1rphiPrIjX8dbK4kFO0ZPLw0/YwrlbpE+avMzVF2ttQ9s5iwGpJv+BR7y8LpsNqKW0Ux N8Ow== 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=FjGKF+9fQR3oX5+16IJIymH9iLuHR5HxuJmit6BGji4=; b=f2eugK1gI/bU8k4Uj8uMD+EqWd0bGxVswWJ2uhrBaxNvXt15YaILetvOQHf3gPKuXy j0+6mtJwiA47yxIt5phnj8NcgmzK3q5PEnMWiGMeph5uqfM78k3t+w7NefbRtEKQ1gnq nRhS9dj3NOByj+n7KzTtVKszp7zQrnAAWquA+DIzSkoDbFyymv0xtJHuVS1fXzalN6qt uZ9UrzsuUID3N07GrpZbrWvnrlb+9DL7VGjhL5/gwYJ8M1prA040uOC3bZ6FYfbvEmFg d+kBkOAb3SxTlAJiF6FpUFEeIqAR/SFMPNWrWdDXVUSAufJwUyG5lhg4IjmRc0sPVSi3 dXyA== X-Gm-Message-State: APjAAAW/nzKdXxTjcaKgBhnleJBZb42m+UDCKJpA+FBT/6rtxOE0ykXl lCVhbYb8gAQWdyBOvbmTUXt6M8aG7xuG X-Received: by 2002:ab0:641a:: with SMTP id x26mr1504316uao.12.1553043879468; Tue, 19 Mar 2019 18:04:39 -0700 (PDT) Date: Tue, 19 Mar 2019 18:04:31 -0700 In-Reply-To: <20190320010431.19833-1-rajatja@google.com> Message-Id: <20190320010431.19833-2-rajatja@google.com> Mime-Version: 1.0 References: <20190313222124.229371-1-rajatja@google.com> <20190320010431.19833-1-rajatja@google.com> X-Mailer: git-send-email 2.21.0.225.g810b269d1ac-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 warn and 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 --- v2: Use pm_suspend_via_firmware() to enable the check only for S0ix (I think). 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..0ab893fac4bb 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 && !pm_suspend_via_firmware() && + !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.225.g810b269d1ac-goog