Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp5831603yba; Thu, 11 Apr 2019 06:42:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqzTCbFRt6URdrOb94+LGcTKnGDe4DKCw8TN2h9MAO6GIBHmfZsSQedflmdK1wam48/jiPCi X-Received: by 2002:a63:5466:: with SMTP id e38mr45524524pgm.340.1554990173964; Thu, 11 Apr 2019 06:42:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554990173; cv=none; d=google.com; s=arc-20160816; b=WkOvQDU6MZje9LWpMNk3Xy7v7dKQS7wTdm7kxdeyDTG1+mx5UJ3cZOHROoF+7g2ven 4xNovkhXV2njr4dxJjG8JO1fp8y5WG5NztpE1Ruxm3Sx/mp3PhhrwJdqjEX6SSVTu3rd lYQgLB7gIXmg6jaukxYHGbAMzOurQV1F5EtSJrMo8xUEmTwaJKEiUtvtKlX5lvJoZC5e BEdbrTBS4pwYapqk1nEkIlUQfSLJ4eTgLpW5KkoHZRTrq4Rnru0L2VLAp4nHrcpsLIE4 ChqrrZyMEvjz1fUfn2gWN4TmUi8IFaOzLNFMzCSzAZO0EGEGwSfsvnNJV8Kgbq/6biDw EnyA== 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=Qr5ItuNMMRfnKTC8qofK6VXacrruJnPxHB8CJe/qgMY=; b=EyBgADLcrCEBZbczh6yqKBanxu4cZue/HZCnt5Kr+KNQdhs8l5jwuii1tZOT8vIB5R 88+++q3aqucB/UJf4MNmyoQ6SyXpOVq3tHWm/M/B5A3F4iehJ0lW+obqwXK7by8p/5nb eAz9qc3pTdRj1x0HUqIThGj+D71k1Y/AD+5mfFq0OI+L1zxJTufeaS8dAba2j057yqvA F8zGXljmtXlobUoC9FFGz36cTN17eRTM8ieSyA3Rg67OeKNYtvVKqRvaYO6HxnQDptDw h+H6WTRgROJ12gfkSslWpEvVcQd3mPjiMqCX4A8tsUVeDnzfQLR0IDHoGPu0txalZAoO jU5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ppC6bO0u; 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 f8si22324411pfd.105.2019.04.11.06.42.37; Thu, 11 Apr 2019 06:42:53 -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=ppC6bO0u; 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 S1726777AbfDKNkt (ORCPT + 99 others); Thu, 11 Apr 2019 09:40:49 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:39644 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726264AbfDKNks (ORCPT ); Thu, 11 Apr 2019 09:40:48 -0400 Received: by mail-pg1-f196.google.com with SMTP id k3so3540153pga.6; Thu, 11 Apr 2019 06:40:48 -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=Qr5ItuNMMRfnKTC8qofK6VXacrruJnPxHB8CJe/qgMY=; b=ppC6bO0uOErcH1ubEDV5XICbR77zwx26wxp+hZKDRbWnpVCHWod0jJcy+zxa948fLJ /1TwuSGOQwb5N1ULbWbfkytSj/pdL+aODldgqkc3XH1elpn1HpJfmS1atEbkWIUc99y6 pGaWS5w9pzfYJaJTN1a2MFblD78PXHl8NfwDwZ2dhwVuENnEg4Bt73jSldfOHpM35E2P X597lR2loq9W4pjEtIjWL2TAiw8CPZPFbbVchSmwHDcSIhju+yo0FQmXjvrsnQsSFrAm dPSgzgkgEX1Wp4Z2hc8cQAh5swBA1ODcNDW4BnWOE6g1oYjj9btWJ1C/I9eVchdySed4 VEzw== 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=Qr5ItuNMMRfnKTC8qofK6VXacrruJnPxHB8CJe/qgMY=; b=FuLZ/QDThkvrjK7kwb2iP+RupSEuKTlNgFp9Br7Ki23tUPqzVMKPXAdmoe5AzoCYMC wJgiyexRwXikjayvcI1qlzTdMfd6N8m+7h+mpWjMHVVunoLJCQhEBe6ibfHibVrgNwTw i/d9PCK7Gwj9/zk/NolQ32D8+S82VsRPbLpcnIhCW2ch7pw7hyPezHV7XvZfflBxhrVV UVeWN1IxYn4qh98XCVQWc1Sg+ORsb9AGio1jW24pED0dWQJKjQyULlNAXVm8EuVQn31U OKGFUPb4iFrJpXsAryzv4qH1gNs3C3+c5zE0uqYrEXEoLEIaVec8IBOmsXYa0rHNoikv 6UsQ== X-Gm-Message-State: APjAAAUehaRj6nybfREtsqXnXOqEz0mM39RMs5ri2N2jalKbwVBP/E/n x0cHSxknkkFjLSoB+VA2phfYvR27VDBjB4eNHyE= X-Received: by 2002:a65:6210:: with SMTP id d16mr45710904pgv.110.1554990048186; Thu, 11 Apr 2019 06:40:48 -0700 (PDT) MIME-Version: 1.0 References: <20190313222124.229371-1-rajatja@google.com> <20190411003738.55073-1-rajatja@google.com> <20190411003738.55073-2-rajatja@google.com> In-Reply-To: <20190411003738.55073-2-rajatja@google.com> From: Andy Shevchenko Date: Thu, 11 Apr 2019 16:40:37 +0300 Message-ID: Subject: Re: [PATCH v5 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 , Rafael J Wysocki , Srinivas Pandruvada , Furquan Shaikh , Evan Green , 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 Thu, Apr 11, 2019 at 3:38 AM 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. > +static int pmc_core_suspend(struct device *dev) > +{ > + struct pmc_dev *pmcdev = dev_get_drvdata(dev); > + > + pmcdev->check_counters = false; > + > + /* No warnings on S0ix failures */ > + if (!warn_on_s0ix_failures) > + return 0; > + > + /* Check if the syspend will actually use S0ix */ > + if (pm_suspend_via_firmware()) > + return 0; > + > + /* Save PC10 and S0ix residency for checking later */ > + if (!rdmsrl_safe(MSR_PKG_C10_RESIDENCY, &pmcdev->pc10_counter) && > + !pmc_core_dev_state_get(pmcdev, &pmcdev->s0ix_counter)) Split it. > + pmcdev->check_counters = true; > + > + return 0; > +} > + > +static inline bool pmc_core_is_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; Split this as well. > + > + return false; > +} > + > +static inline bool pmc_core_is_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; And this. > + > + 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 (pmc_core_is_pc10_failed(pmcdev)) { > + dev_info(dev, "PC10 entry had failed (PC10 cnt=0x%llx)\n", > + pmcdev->pc10_counter); > + } else if (pmc_core_is_s0ix_failed(pmcdev)) { > + Redundant. > + 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; map++; > + } > + ++maps; maps++; > + } This is quite noisy. You need to print only what is important. I don't think polluting dmesg with piles of these kind of messages is a good idea. Also, it is more likely should be done on debug level (except may be one or two messages with really important information). > + } > + return 0; > +} > + > +#endif -- With Best Regards, Andy Shevchenko