All of lore.kernel.org
 help / color / mirror / Atom feed
From: Finn Thain <fthain@telegraphics.com.au>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Michael Schmitz <schmitzmic@gmail.com>,
	<linuxppc-dev@lists.ozlabs.org>,
	<linux-m68k@lists.linux-m68k.org>, <linux-kernel@vger.kernel.org>
Subject: [PATCH v2 12/12] macintosh/via-pmu: Disambiguate interrupt statistics
Date: Thu,  7 Jun 2018 22:24:29 -0400 (EDT)	[thread overview]
Message-ID: <2b0138faa6313416576fcf760226ef70e8655cd3.1528423341.git.fthain@telegraphics.com.au> (raw)
In-Reply-To: <cover.1528423341.git.fthain@telegraphics.com.au>

Some of the event counters are overloaded which makes it very
difficult to interpret their values.

Counter 0 is supposed to report CB1 interrupts but it can also count
PMU_INT_WAITING_CHARGER events.

Counter 1 is supposed to report GPIO interrupts but it can also count
other events (depending upon the value of the PMU_INT_ADB bit).

Disambiguate these statistics with dedicated counters for GPIO and
CB1 interrupts.

Comments in the MkLinux source code say that the type 0 and type 1
interrupts are model-specific. Label them as "unknown".

This change to the contents of /proc/pmu/interrupts is by necessity
visible in userland. However, packages which interact with the PMU
(that is, pbbuttonsd, pmac-utils and pmud) don't open this file.
AFAIK, user software has no need to poll these counters.

Tested-by: Stan Johnson <userm57@yahoo.com>
Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
---
The file now looks like this,

  0:          0 (Unknown interrupt (type 0))
  1:          0 (Unknown interrupt (type 1))
  2:          0 (PC-Card eject button)
  3:         23 (Sound/Brightness button)
  4:         74 (ADB message)
  5:          0 (Battery state change)
  6:          0 (Environment interrupt)
  7:        121 (Tick timer)
  8:          0 (Ghost interrupt (zero len))
  9:          1 (Empty interrupt (empty mask))
 10:          2 (Max irqs in a row)
 11:        194 (Total CB1 triggered events)
 12:          0 (Total GPIO1 triggered events)

rather than this,

  0:        194 (Total CB1 triggered events)
  1:          0 (Total GPIO1 triggered events)
  2:          0 (PC-Card eject button)
  3:         23 (Sound/Brightness button)
  4:         74 (ADB message)
  5:          0 (Battery state change)
  6:          0 (Environment interrupt)
  7:        121 (Tick timer)
  8:          0 (Ghost interrupt (zero len))
  9:          1 (Empty interrupt (empty mask))
 10:          2 (Max irqs in a row)

If some parser exists for this file, and if this change is problematic,
we could increment the driver version number in /proc/pmu/info, to
correspond with the format change.
---
 drivers/macintosh/via-pmu.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c
index 730c10f7fbb7..44919b3b56e0 100644
--- a/drivers/macintosh/via-pmu.c
+++ b/drivers/macintosh/via-pmu.c
@@ -172,7 +172,9 @@ static int drop_interrupts;
 static int option_lid_wakeup = 1;
 #endif /* CONFIG_SUSPEND && CONFIG_PPC32 */
 static unsigned long async_req_locks;
-static unsigned int pmu_irq_stats[11];
+
+#define NUM_IRQ_STATS 13
+static unsigned int pmu_irq_stats[NUM_IRQ_STATS];
 
 static struct proc_dir_entry *proc_pmu_root;
 static struct proc_dir_entry *proc_pmu_info;
@@ -884,9 +886,9 @@ static const struct file_operations pmu_info_proc_fops = {
 static int pmu_irqstats_proc_show(struct seq_file *m, void *v)
 {
 	int i;
-	static const char *irq_names[] = {
-		"Total CB1 triggered events",
-		"Total GPIO1 triggered events",
+	static const char *irq_names[NUM_IRQ_STATS] = {
+		"Unknown interrupt (type 0)",
+		"Unknown interrupt (type 1)",
 		"PC-Card eject button",
 		"Sound/Brightness button",
 		"ADB message",
@@ -895,10 +897,12 @@ static int pmu_irqstats_proc_show(struct seq_file *m, void *v)
 		"Tick timer",
 		"Ghost interrupt (zero len)",
 		"Empty interrupt (empty mask)",
-		"Max irqs in a row"
+		"Max irqs in a row",
+		"Total CB1 triggered events",
+		"Total GPIO1 triggered events",
         };
 
-	for (i=0; i<11; i++) {
+	for (i = 0; i < NUM_IRQ_STATS; i++) {
 		seq_printf(m, " %2u: %10u (%s)\n",
 			     i, pmu_irq_stats[i], irq_names[i]);
 	}
@@ -1659,7 +1663,7 @@ via_pmu_interrupt(int irq, void *arg)
 		}
 		if (intr & CB1_INT) {
 			adb_int_pending = 1;
-			pmu_irq_stats[0]++;
+			pmu_irq_stats[11]++;
 		}
 		if (intr & SR_INT) {
 			req = pmu_sr_intr();
@@ -1746,7 +1750,7 @@ gpio1_interrupt(int irq, void *arg)
 			disable_irq_nosync(gpio_irq);
 			gpio_irq_enabled = 0;
 		}
-		pmu_irq_stats[1]++;
+		pmu_irq_stats[12]++;
 		adb_int_pending = 1;
 		spin_unlock_irqrestore(&pmu_lock, flags);
 		via_pmu_interrupt(0, NULL);
-- 
2.16.4

  parent reply	other threads:[~2018-06-08  2:25 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-08  2:24 [PATCH v2 00/12] macintosh: Resolve various PMU driver problems Finn Thain
2018-06-08  2:24 ` [PATCH v2 02/12] macintosh/via-pmu: Add missing mmio accessors Finn Thain
2018-06-08  2:24 ` [PATCH v2 01/12] macintosh/via-pmu: Fix section mismatch warning Finn Thain
2018-06-08  2:24 ` [PATCH v2 03/12] macintosh/via-pmu: Don't clear shift register interrupt flag twice Finn Thain
2018-06-08  2:24 ` [PATCH v2 07/12] macintosh/via-pmu: Make CONFIG_PPC_PMAC Kconfig deps explicit Finn Thain
2018-06-08  2:24 ` [PATCH v2 10/12] macintosh: Use common code to access RTC Finn Thain
2018-06-08  2:24   ` Finn Thain
2018-06-08  2:24 ` [PATCH v2 08/12] macintosh/via-pmu68k: Don't load driver on unsupported hardware Finn Thain
2018-06-09  6:42   ` Michael Schmitz
2018-06-09  7:14     ` Andreas Schwab
2018-06-09  7:55       ` Michael Schmitz
2018-06-09 12:21         ` Finn Thain
2018-06-09 13:24           ` Andreas Schwab
2018-06-10  2:11             ` Finn Thain
2018-06-10  6:55           ` Benjamin Herrenschmidt
2018-06-11 23:47             ` Finn Thain
2018-06-12  6:53               ` Laurent Vivier
2018-06-12 20:12                 ` Michael Schmitz
2018-06-10  8:29           ` Geert Uytterhoeven
2018-06-10  9:12             ` Michael Schmitz
2018-06-11  0:05               ` Benjamin Herrenschmidt
2018-06-11  1:45                 ` Michael Schmitz
2018-06-08  2:24 ` [PATCH v2 05/12] macintosh/via-pmu: Replace via pointer with via1 and via2 pointers Finn Thain
2018-06-08  2:24 ` [PATCH v2 09/12] macintosh/via-pmu: Replace via-pmu68k driver with via-pmu driver Finn Thain
2018-06-08  2:24 ` [PATCH v2 06/12] macintosh/via-pmu: Add support for m68k PowerBooks Finn Thain
2018-06-08  2:24 ` Finn Thain [this message]
2018-06-08  2:24 ` [PATCH v2 11/12] macintosh/via-pmu: Clean up interrupt statistics Finn Thain
2018-06-08  2:24 ` [PATCH v2 04/12] macintosh/via-pmu: Enhance state machine with new 'uninitialized' state Finn Thain

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2b0138faa6313416576fcf760226ef70e8655cd3.1528423341.git.fthain@telegraphics.com.au \
    --to=fthain@telegraphics.com.au \
    --cc=benh@kernel.crashing.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-m68k@lists.linux-m68k.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=schmitzmic@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.