Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3051946yba; Mon, 8 Apr 2019 10:03:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqzu/NWk4weeICHJTFOjG+1rZAjsCZBDHpYS82dSZS5q/bkvXsg1RQKDuVI5uC0tZ2XF27eP X-Received: by 2002:a17:902:7892:: with SMTP id q18mr31020832pll.163.1554743017801; Mon, 08 Apr 2019 10:03:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554743017; cv=none; d=google.com; s=arc-20160816; b=fnCwFNHzD1z1gkc2nWWa76yuKnXZXPwnEBNL7MSFBIknTauoNRQ5MxUoogp6h4E179 62wm0b1eJeCUaD8/1k/oCcK8XKyLSOE11tmvuDWD/OGGWZPfAQwmIuxQgt4NFBooGyC0 v/tZWfiOcjSr4FGjDiw6Cp2LCVBVSD9xZACuALoSTsF5o1Jy7WWlmn+vrVT/GD/ZrwpO xQCQdmsmkOm+4ZIhzsrE3WibxDl1X0TCmd2oAtNLqMT/R7e216Mnl9qjaUEFPXwRsVBy uxdQ63LZSnn0h6+xozGfAifldgCFDWBszU/FokElMLR06SqhB1kOYbEkJ3jtIA3XySff Cd/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=cNVymU67Q9OWVolqOTZRo9qx2gflcB8P7kTX1YrlXIc=; b=hbiES89uwhlnT//MzIVTAkNo0Ca4IadxwPQ3gPQkg84AXSMMn0ruba+ROi5739bGpi Fn+PWwfutmaoYwrR82qj40J+333Ji3pfC9jPDgjPxfxm5Slm5ibmr974wlwakByhFWIg 4lx2+KKCICR3l502o+9Bt+5+lcbtsGaB2Sp0KneKFp0F/rWlfDJNo3OJLYELuyD0Hg8M bymVGPIbDCXOifJ+h6YqunMjJTMcZ4tMecv2rRxz0BB2c01Vb1jZRARig1x+921+i2pL XBKFEgmOk9JqlH1+Jgz/+if4LtVwnBRyS4SuYZCt2DD/jL2Rh776d3OevgpxsVxijRiE n08g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Z+97eb5N; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f7si27533716pgg.234.2019.04.08.10.03.21; Mon, 08 Apr 2019 10:03:37 -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=@gmail.com header.s=20161025 header.b=Z+97eb5N; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729126AbfDHRCh (ORCPT + 99 others); Mon, 8 Apr 2019 13:02:37 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:35055 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728933AbfDHRCh (ORCPT ); Mon, 8 Apr 2019 13:02:37 -0400 Received: by mail-pg1-f196.google.com with SMTP id g8so7675320pgf.2; Mon, 08 Apr 2019 10:02:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=cNVymU67Q9OWVolqOTZRo9qx2gflcB8P7kTX1YrlXIc=; b=Z+97eb5N9+y6fJNSsO1y/+cGaGWOtwwcbVnyp1urn0wkVRAODHpbhyYVqr8l/J8IZg nsoRIWZ0X5IT8pUV7da4prdjn7YERZnPekRgNQiBOGyvcdTHXCVjtWLoz95pXrbCcXOH aHP2bzFW+B/k+xoeyXyQz7ofmFnhcvjxoKS2zEVVfsgHEf+LM1S8BlsOyrywayetPSrw hpO32RJdtOBnNnz2p6exnv0s4OemnefCytTW66PlWegGaSLbB83pkIa2WKawC5MpP9lX SZpQyud0/qyHkCA1ao3BQa8HtR6XN0Xmoh1UMloFCrOQuqw9xQBOLbzb3mw4SHPbGHiT M2+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=cNVymU67Q9OWVolqOTZRo9qx2gflcB8P7kTX1YrlXIc=; b=DJ08fM4gC6Py5kBoJSmQ2gMEp2PbpdLHgeDp0rSPK6YePNNbOZK5fGb4J8lTwm/51+ Gf2CGMZ+C9VX8LIW1xHBSZFFQJRGgn4sP5Zut2jPzdrRu11eRVCBN7I7d2/RnKOMQNZd C4VJJqu/cgRpaKYZcaeEaOELM/ucYMih0823tCBFPj9w4oPyTKqdC4KzzdvJsJBwkJmm pryILkG58YheBCY8Ov95d37CM3ZRN97G/6mtvRw73Qvq869GDAv4rhlCYMnPCCqSVRS9 bnrGAVNImvb/G6GqsVIwtqBFaSSPwrZWBONw2Y26f4kJPkNSaqUA+0aK6Sl7jzGcsS1a N/Dg== X-Gm-Message-State: APjAAAXJgUydD7pypYZX77uncSGTBCuuVrrzvV99lsPyD5UDoFYoLb6Q pAjNw5volrRtlDY1buGJgGWteqNNgXIlSgMMMqt8G49qZ/8= X-Received: by 2002:a65:4302:: with SMTP id j2mr28110422pgq.291.1554742956028; Mon, 08 Apr 2019 10:02:36 -0700 (PDT) MIME-Version: 1.0 References: <20190313222124.229371-1-rajatja@google.com> <20190405203558.19160-1-rajatja@google.com> <20190405203558.19160-2-rajatja@google.com> In-Reply-To: <20190405203558.19160-2-rajatja@google.com> From: Andy Shevchenko Date: Mon, 8 Apr 2019 20:02:25 +0300 Message-ID: Subject: Re: [PATCH v3 2/3] platform/x86: intel_pmc_core: Allow to dump debug registers on S0ix failure To: Rajat Jain Cc: Rajneesh Bhardwaj , Vishwanath Somayaji , Darren Hart , Andy Shevchenko , Platform Driver , Linux Kernel Mailing List , Wysocki@google.com, Rafael J , Srinivas Pandruvada , furquan@google.com, evgreen@google.com, Rajat Jain 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 On Fri, Apr 5, 2019 at 11:36 PM Rajat Jain wrote: > > 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. > +#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; Perhaps something like pmcdev->check_counters = false; /* User doesn't want to be warned */ if (!warn_on...) return 0; /* We do suspend via firmware */ if (...) return 0; ... ? > + else > + pmcdev->check_counters = false; > + > + return 0; > +} > + > +static inline bool pc10_failed(struct pmc_dev *pmcdev) To be or not to be? :-) Perhaps names of the functions should be pmc_code_is_pc10_failed() and so on > +{ > + u64 pc10_counter; > + > + if (!rdmsrl_safe(MSR_PKG_C10_RESIDENCY, &pc10_counter) && > + pc10_counter == pmcdev->pc10_counter) > + return true; > + else Redundant. > + 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 Ditto. > + 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; > + } Can't we utilize existing print helpers? > + } > + return 0; > +} > + > +#endif -- With Best Regards, Andy Shevchenko